I am new to Dojo and I want to be able to use the RSA module to encrypt some information using a public key that is received from a website.
Is there any information or examples on how to do this?
I have found the library dojox.encoding.crypto.RSAKey but there is no information: https://dojotoolkit.org/reference-guide/1.9/dojox/encoding/crypto/RSAKey.html
I found Dojo because I was researching: http://www-cs-students.stanford.edu/~tjw/jsbn/
Now I want to learn Dojo but my primary reason to use it is the RSA library.
Ps.: I don't want to be lectured on the dangers of RSA on the client side, neither why I shouldn't be doing RSA on JavaScript side.
EDITED: replaced example values with provided ones.
I'm not familiar with RSA, but general use of dojo's RSAKey module would be as follow (according to its source code ):
require([ "dojo/dom", "dojox/encoding/crypto/RSAKey" ],function(dom, RSAKeyModule){ var RSAKey = new RSAKeyModule(); var n= "8efebfa74157b9447e1bc729d5e2a459ee888e87dc7ed764b473e513edba7696a957871ff7a4941ed360d1b42a9788bdc52a8b659357dc8f252e6cc5f5bbf5c659cc9e9837df4ca6eee1c47889b055ac3802bb9491e88483491b08dff9e9472d99341134bcfc4ecf38915553bda08f943089377a95c7118febcef2841288aedb1b8ba22e211da2ab527d26d7accf2e05421260a23f06cf2b13e0ffd51e8f401bc113768027ad29c371564d179c82639061272e4f940bf50ba6490933f788715f8c268dd2c85a461e899ba416a51557fec7a9a4f1ed3df95cf5bd14bb529dd331b9a79828366a9589deb32e730369cd62352ef7fdd9297e1193f4a33e01289a6f" var e = "10001"; RSAKey.setPublic(n, e); var encrypted = RSAKey.encrypt("abc"); dom.byId("result").innerHTML = encrypted; });
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script> <div id="result"></div>
See dojo/request/xhr module - could be helpful for receiving key.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.