Simple Stupid Encryption
const {enc, dec} = require("./enc.js");
btoa = x => Buffer.from(x).toString('base64');
atob = x => Buffer.from(x, 'base64').toString();
function encrypt(text) {
return btoa([...new Array(text.length)].map((_,i) => (enc(text[i].charCodeAt(0)))).join(":"))
}
function decrypt(e) {
return atob(e).split(":").map(x => String.fromCharCode(dec(+x))).join("")
}
const original = "https://stackoverflow.com/questions/12332002/how-to-store-a-byte-array-in-javascript️"
const encrypted = encrypt(original)
console.log(encrypted);
const decrypted = decrypt(encrypted);
console.log(decrypted)
console.log(decrypted === original)INFO