MCPcopy Create free account
hub / github.com/Effect-TS/effect / digest

Function digest

packages/platform/browser/src/BrowserCrypto.ts:69–92  ·  view source on GitHub ↗
(algorithm, data)

Source from the content-addressed store, hash-verified

67 }
68
69 const digest: EffectCrypto.Crypto["digest"] = (algorithm, data) => {
70 if (typeof crypto.subtle.digest !== "function") {
71 return Effect.fail(PlatformError.systemError({
72 module: "Crypto",
73 method: "digest",
74 _tag: "Unknown",
75 description: "crypto.subtle.digest is not available"
76 }))
77 }
78 return Effect.map(
79 Effect.tryPromise({
80 try: () => crypto.subtle.digest(algorithm, new Uint8Array(data)),
81 catch: (cause) =>
82 PlatformError.systemError({
83 module: "Crypto",
84 method: "digest",
85 _tag: "Unknown",
86 description: "Could not compute digest",
87 cause
88 })
89 }),
90 (buffer) => new Uint8Array(buffer)
91 )
92 }
93
94 return EffectCrypto.make({
95 randomBytes,

Callers

nothing calls this directly

Calls 3

digestMethod · 0.80
failMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected