MCPcopy Create free account
hub / github.com/arctic-cli/interface / hash

Function hash

packages/util/src/encode.ts:9–16  ·  view source on GitHub ↗
(content: string, algorithm = "SHA-256")

Source from the content-addressed store, hash-verified

7}
8
9export async function hash(content: string, algorithm = "SHA-256"): Promise<string> {
10 const encoder = new TextEncoder()
11 const data = encoder.encode(content)
12 const hashBuffer = await crypto.subtle.digest(algorithm, data)
13 const hashArray = Array.from(new Uint8Array(hashBuffer))
14 const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("")
15 return hashHex
16}
17
18export function checksum(content: string): string {
19 let hash = 0x811c9dc5

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected