简体   繁体   中英

Dojo RSA configuration and usage

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= "8efebfa74157b9447e1bc729d5e2a459ee888e87dc7ed764b473e513edba‌​7696a957871ff7a4941e‌​d360d1b42a9788bdc52a‌​8b659357dc8f252e6cc5‌​f5bbf5c659cc9e9837df‌​4ca6eee1c47889b055ac‌​3802bb9491e88483491b‌​08dff9e9472d99341134‌​bcfc4ecf38915553bda0‌​8f943089377a95c7118f‌​ebcef2841288aedb1b8b‌​a22e211da2ab527d26d7‌​accf2e05421260a23f06‌​cf2b13e0ffd51e8f401b‌​c113768027ad29c37156‌​4d179c82639061272e4f‌​940bf50ba6490933f788‌​715f8c268dd2c85a461e‌​899ba416a51557fec7a9‌​a4f1ed3df95cf5bd14bb‌​529dd331b9a79828366a‌​9589deb32e730369cd62‌​352ef7fdd9297e1193f4‌​a33e01289a6f" 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM