Public
Edited
Jul 9, 2023
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
key1 = [
0b11100000,
0b00011100,
0b00000011,
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chunkString = (str, len) => {
return str.match(new RegExp('.{1,' + len + '}', 'g'))
}
Insert cell
chunkArr = (arr, chunkSize) => {
let chunks = [];
for (let i = 0; i < arr.length; i += chunkSize) {
chunks.push(arr.slice(i, i+chunkSize));
}
return chunks;
}
Insert cell
strToArr = (s) => {
let r = [];
for (let i = 0; i < s.length; i += 1) {
r.push(s.charCodeAt(i));
}
return r
}
Insert cell
arrToStr = (arr) => arr.map(chr).join("")
Insert cell
Insert cell
encryptRaw = (s, k) => {
let chunks = chunkString(s, k.length);
let r = [];
for (let ch of chunks) {
for (let i = 0; i < ch.length; i += 1) {
r.push(atoi(ch[i]) ^ k[i]);
}
}

return r
}
Insert cell
decrypt = (arr, k) => {
let r = [];
for (let i =0; i < arr.length; i += k.length) {
for (let j = 0; j < k.length; j += 1) {
if ((i + j) >= arr.length) {
break;
}
r.push(arr[i + j] ^ atoi(k[j]));
}
}
return r
}
Insert cell
decryptRaw = (arr, k) => {
let r = [];
for (let i =0; i < arr.length; i += k.length) {
for (let j = 0; j < k.length; j += 1) {
if ((i + j) >= arr.length) {
break;
}
r.push(arr[i + j] ^ k[j]);
}
}
return r
}
Insert cell
import {lib} from "@pcarleton/cryptopals-helpers"
Insert cell
atoi('a')
Insert cell
Insert cell
Insert cell
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