Public
Edited
Jan 20, 2023
Insert cell
Insert cell
ex1 = "foo=bar&baz=qux&zap=zazzle"
Insert cell
import {lib, CryptoJS, aes} from "05612030f3f61d48"
Insert cell
parseQuery = (q) => Object.fromEntries((new URLSearchParams(q)).entries())
Insert cell
parseQuery(ex1)
Insert cell
profile_for = (email) => {
const qp = new URLSearchParams();

qp.set("email", email);
qp.set("uid", 213);
qp.set("role", "user");


return qp.toString()
}

Insert cell
profile_for("a@b.co")
Insert cell
key = lib.ByteArray.fromWordArray(CryptoJS.lib.WordArray.random(16));
Insert cell
aes.encryptAes128Ecb(lib.ByteArray.fromString(profile_for("a@gmail.com")), key).toHex()
Insert cell
encryptProfile = (email) => {
return aes.encryptAes128Ecb(lib.ByteArray.fromString(profile_for(email)), key)
}
Insert cell
ep1 = encryptProfile(email)
Insert cell
ep1.toHex()
Insert cell
Insert cell
decryptProfile = (profile) => {
return aes.decryptAes128Ecb(profile, key)
}
Insert cell
dp1 = decryptProfile(ep1)
Insert cell
good_prefix = new lib.ByteArray(ep1.bytes.slice(0,32).concat(aes.padBlock([], 16)))
Insert cell
{
let attempt = new lib.ByteArray(ep1.bytes.slice(0,32).concat(emptyPaddingEnd.bytes))
return [attempt, decryptProfile(attempt).toString()]
}
Insert cell
lib.toHex(lib.chunkArr(ep1.bytes, 16)[1])
Insert cell
Insert cell
decryptProfile(good_prefix)
Insert cell
getBlock = (arr, idx) => lib.chunkArr(arr, 16)[idx]
Insert cell
ep1.toHex()
Insert cell
Insert cell
drawByteArray(dp1)
Insert cell
emptyPaddingEnd = {
const email = "abcdefgh";
const cipher = encryptProfile(email);
return cipher.slice(32, 48)
}
Insert cell
roleStart3rdBlock = encryptProfile("123456789012").slice(0,32)
Insert cell
startsWithAdmin = {
const email = " admin";
const cipher = encryptProfile(email);
return cipher.slice(16, 32)
}
Insert cell
decryptProfile(startsWithAdmin.concat(emptyPaddingEnd)).toString()
Insert cell
Insert cell
newBlocks = roleStart3rdBlock.concat(startsWithAdmin).concat(emptyPaddingEnd);

Insert cell
admint1 = {
//const og = lib.ByteArray.fromHex("a9e8dc0a0d6f1c190235577587cd8af045604f6d396e5f3336a10c5d0920985712de6170c0fa7a6a3dc3d9efaa08e686");
return decryptProfile(newBlocks).toString()
}
Insert cell
parseQuery(admint1)
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