1const baseString = 'konrad';
2const encodedString = window.btoa( baseString ); // "a29ucmFk"
3const decodedString = window.atob( encodedString ); //konrad
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}
1const Cryptr = require('cryptr');const cryptr = new Cryptr('myTotalySecretKey'); const encryptedString = cryptr.encrypt('bacon');const decryptedString = cryptr.decrypt(encryptedString); console.log(encryptedString); // e7b75a472b65bc4a42e7b3f78833a4d00040beba796062bf7c13d9533b149e5ec3784813dc20348fdf248d28a2982df85b83d1109623bce45f08238f6ea9bd9bb5f406427b2a40f969802635b8907a0a57944f2c12f334bd081d5143a357c173a611e1b64aconsole.log(decryptedString); // bacon