Platform
Resources
Pricing
Sign in
Get started
Nicola
Working to decentralize the web
Workspace
Fork
Public
By
Nicola
Edited
Jun 22, 2023
Paused
Fork of
Encrypted Message
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.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
input
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
encrypted
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
decrypted
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
encrypt
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
defaultKeyExported
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
newExportedKey
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
activeKeyExported
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
decrypt
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
activeKey
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
hash
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
encode
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
decode
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML