Public
Edited
Jan 16, 2023
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
CryptoJS.AES.decrypt(ciphertext.text, key)
Insert cell
Insert cell
decrypted2 = CryptoJS.AES.decrypt(ciphertext.text, key, {mode: CryptoJS.mode.ECB })
Insert cell
decrypted2.toString()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
decrypted3 = CryptoJS.AES.decrypt(cipherBytes, lib.fromHex(hexKey), {mode: CryptoJS.mode.ECB })
Insert cell
encryptTest1 = CryptoJS.AES.encrypt("hi there", hexKey, {mode: CryptoJS.mode.ECB })
Insert cell
CryptoJS.AES.decrypt(encryptTest1, hexKey, {mode: CryptoJS.mode.ECB })
Insert cell
Insert cell
key2 = CryptoJS.enc.Hex.parse(hexKey)
Insert cell
encryptTest2 = CryptoJS.AES.encrypt("hi there", key2, {mode: CryptoJS.mode.ECB })
Insert cell
// Aha! was an encoding problem
CryptoJS.AES.decrypt(encryptTest2, key2, {mode: CryptoJS.mode.ECB }).toString(CryptoJS.enc.Utf8)
Insert cell
CryptoJS.AES.decrypt(encryptTest1, hexKey, {mode: CryptoJS.mode.ECB }).toString(CryptoJS.enc.Utf8)
Insert cell
Insert cell
decrypted = CryptoJS.AES.decrypt(no_newlines, key2, {mode: CryptoJS.mode.ECB })
Insert cell
decrypted.toString()
Insert cell
no_newlines = ciphertext.text.replaceAll("\n", "")
Insert cell
decrypted.toString(CryptoJS.enc.Utf8)
Insert cell
decryptAes128Ebc = (cipher, key) => {
const encKey = CryptoJS.enc.Utf8.parse(key);

// The challenge input includes newlines, but we want to ignore them.
// It's a PEM like encoding
const fixedCipher = cipher.replaceAll("\n", "");

return CryptoJS.AES.decrypt(fixedCipher, encKey, {mode: CryptoJS.mode.ECB }) //.toString(CryptoJS.enc.Utf8)
}
Insert cell
decryptAes128Ebc(ciphertext.text, key)
Insert cell
ciphertext.text.replaceAll("\n", "").slice(0, 86)
Insert cell
shorter = lib.tob64(lib.fromb64(ciphertext.text.replaceAll("\n", "")).slice(0,64))
Insert cell
encryptTest3 = CryptoJS.AES.encrypt("I'm back and I'm ringin' the bell ", key2, {mode: CryptoJS.mode.ECB }).toString()
Insert cell
decryptAes128Ebc(encryptTest3, key)
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more