简体   繁体   中英

Is there a faster method of decrypting RSA via javascript than cryptico

I am using cryptico to encrypt and decrypt data, but when decrypting 3-4 piece of data at once, cryptico can take up to 10 seconds and freezes the browser. Is there any faster way to decrypt RSA data using javascript?

I must admit cyrto algorithms is not my strong point..

But using details from here -> https://github.com/diafygi/webcrypto-examples

I've knocked up a little snippet that encodes and then decodes a message.

 async function test() { const key = await window.crypto.subtle.generateKey( { name: "RSA-OAEP", modulusLength: 2048, //can be 1024, 2048, or 4096 publicExponent: new Uint8Array([0x01, 0x00, 0x01]), hash: {name: "SHA-256"}, }, false, ["encrypt", "decrypt"] ); const data = new TextEncoder().encode("some private message.."); const enc_data = await window.crypto.subtle.encrypt( { name: "RSA-OAEP" }, key.publicKey, data ); const dec_data = await window.crypto.subtle.decrypt( { name: "RSA-OAEP" }, key.privateKey, enc_data ); const decoded = new TextDecoder().decode(dec_data); console.log(decoded); } test(); 

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