Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4433486
test_crypto_subtle_digest.mjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
680 B
Referenced Files
None
Subscribers
None
test_crypto_subtle_digest.mjs
View Options
import assert from "node:assert";
const data = new TextEncoder().encode("ant");
const digest = await crypto.subtle.digest("SHA-256", data);
assert.ok(digest instanceof ArrayBuffer);
const hex = Array.from(new Uint8Array(digest))
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("");
assert.equal(hex, "67a333356cdc566e6e346b5718447308ec0e25f47e623161fb03962b327a651f");
const viaModule = await (await import("node:crypto")).webcrypto.subtle.digest(
{ name: "SHA-256" },
data,
);
assert.ok(viaModule instanceof ArrayBuffer);
assert.equal(
Array.from(new Uint8Array(viaModule))
.map((byte) => byte.toString(16).padStart(2, "0"))
.join(""),
hex,
);
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, May 2, 5:41 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
543020
Default Alt Text
test_crypto_subtle_digest.mjs (680 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment