MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / sha256Hex

Function sha256Hex

packages/core/sdk/src/blob.ts:163–169  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

161 * write-once blobs (`put(key(hash), …)` is then idempotent and orphaned
162 * writes are harmless). Web Crypto, so it runs on Workers/Bun/Node alike. */
163export const sha256Hex = (text: string): Effect.Effect<string> =>
164 Effect.promise(async () => {
165 const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
166 return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join(
167 "",
168 );
169 });
170
171const blobId = (namespace: string, key: string): string => JSON.stringify([namespace, key]);
172

Callers 6

spec-blob.test.tsFile · 0.90
addSpecFunction · 0.90
updateSpecFunction · 0.90

Calls 2

encodeMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected