1const Cryptr = require('cryptr');
2const cryptr = new Cryptr('ReallySecretKey');
3
4const encryptedString = cryptr.encrypt('Popcorn');
5const decryptedString = cryptr.decrypt(encryptedString);
6
7console.log(encryptedString);
1function getMessageEncoding() {
2 const messageBox = document.querySelector(".rsa-oaep #message");
3 let message = messageBox.value;
4 let enc = new TextEncoder();
5 return enc.encode(message);
6}
7
8function encryptMessage(publicKey) {
9 let encoded = getMessageEncoding();
10 return window.crypto.subtle.encrypt(
11 {
12 name: "RSA-OAEP"
13 },
14 publicKey,
15 encoded
16 );
17}