Public
Edited
Jun 22, 2023
Paused
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
decrypted = decrypt(activeKey, "OY/cBqFXWxZX1a8qMA==")
Insert cell
Insert cell
async function encrypt(key, message) {
return base64(
await crypto.subtle.encrypt(
{name: "AES-CTR", counter: new Uint8Array(16), length: 16 * 8},
key,
encode(message)
)
);
}
Insert cell
defaultKeyExported = newExportedKey()
Insert cell
async function newExportedKey () {
return crypto.subtle.exportKey(
"jwk",
await crypto.subtle.generateKey(
{name: "AES-CTR", length: 256},
true,
["encrypt", "decrypt"]
)
)
}
Insert cell
activeKeyExported = crypto.subtle.exportKey(
"jwk",
activeKey
)
Insert cell
async function decrypt(key, message) {
return decode(
await crypto.subtle.decrypt(
{name: "AES-CTR", counter: new Uint8Array(16), length: 16 * 8},
key,
unbase64(message)
)
);
}
Insert cell
activeKey = crypto.subtle.importKey(
"jwk",
{
alg: "A256CTR",
ext: true,
k: hash.slice(1) || defaultKeyExported.k,
key_ops: ["encrypt", "decrypt"],
kty: "oct"
},
{name: "AES-CTR", length: 256},
true,
["encrypt", "decrypt"]
)
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@152"
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