Published
Edited
Mar 17, 2022
1 fork
Importers
30 stars
Insert cell
Insert cell
decrypt("i+bqT/CxfJpw41fiWQ==")
Insert cell
async function decrypt(message) {
return decode(
await crypto.subtle.decrypt(
{name: "AES-CTR", counter: new Uint8Array(16), length: 16 * 8},
key,
unbase64(message)
)
);
}
Insert cell
Insert cell
Insert cell
encrypt(input)
Insert cell
async function encrypt(message) {
return base64(
await crypto.subtle.encrypt(
{name: "AES-CTR", counter: new Uint8Array(16), length: 16 * 8},
key,
encode(message)
)
);
}
Insert cell
Insert cell
newKey = crypto.subtle.exportKey(
"jwk",
await crypto.subtle.generateKey(
{name: "AES-CTR", length: 256},
true,
["encrypt", "decrypt"]
)
)
Insert cell
Insert cell
key = crypto.subtle.importKey(
"jwk",
{
alg: "A256CTR",
ext: true,
k: hash.slice(1) || defaultKey,
key_ops: ["encrypt", "decrypt"],
kty: "oct"
},
{name: "AES-CTR", length: 256},
true,
["encrypt", "decrypt"]
)
Insert cell
defaultKey = "change-me-change-me-change-me-change-me-pls"
Insert cell
hash = Generators.observe(notify => {
const hashchange = () => notify(location.hash);
hashchange();
addEventListener("hashchange", hashchange);
return () => removeEventListener("hashchange", hashchange);
})
Insert cell
encode = (string, encoding) => new TextEncoder(encoding).encode(string)
Insert cell
decode = (buffer, encoding) => new TextDecoder(encoding).decode(buffer)
Insert cell
import {encode as base64, decode as unbase64} from "@mbostock/base64"
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