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

Function decryptData

docs/bitty.js:310–323  ·  view source on GitHub ↗
(cipher, base64, password)

Source from the content-addressed store, hash-verified

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?");
313 if (!pass) return (base64);
314 return subtleDecryptData(base64, pass)
315 return new Promise((resolve, reject) => {
316 loadScript("/js/crypto-js.min.js").then(() => {
317 var words = CryptoJS.enc.Base64.parse(base64);
318 let decrypted = CryptoJS[cipher.toUpperCase()].decrypt(words, pass);
319 console.log(decrypted, CryptoJS.enc.Base64.stringify(decrypted))
320 return resolve(CryptoJS.enc.Base64.stringify(decrypted));
321 })
322 })
323}
324/**
325 * Concatenate two buffers
326 * @param {Uint8Array} buffer1 - first buffer

Callers 1

DataURLClass · 0.85

Calls 3

subtleDecryptDataFunction · 0.85
parseMethod · 0.80
loadScriptFunction · 0.70

Tested by

no test coverage detected