(text: string)
| 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. */ |
| 163 | export 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 | |
| 171 | const blobId = (namespace: string, key: string): string => JSON.stringify([namespace, key]); |
| 172 |
no test coverage detected