MCPcopy Create free account
hub / github.com/arfct/itty-bitty / encryptData

Function encryptData

docs/bitty.js:299–309  ·  view source on GitHub ↗
(cipher, pass, base64)

Source from the content-addressed store, hash-verified

297
298
299async function encryptData(cipher, pass, base64) {
300 let encrypted = await subtleEncryptData(base64, pass);
301 return encrypted
302 return new Promise((resolve, reject) => {
303 loadScript("/js/crypto-js.min.js").then(() => {
304 console.log("encrypting", cipher)
305 let encrypted = CryptoJS[cipher.toUpperCase()].encrypt(base64, pass);
306 return resolve(CryptoJS.enc.Base64.stringify(encrypted));
307 })
308 })
309}
310async function decryptData(cipher, base64, password) {
311 console.log("🔐 Decrypting data:", cipher);
312 let pass = password || prompt("This page is encrypted. What's the passcode?");

Callers 1

DataURLClass · 0.85

Calls 2

subtleEncryptDataFunction · 0.85
loadScriptFunction · 0.70

Tested by

no test coverage detected