(content: string, algorithm = "SHA-256")
| 7 | } |
| 8 | |
| 9 | export 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 | |
| 18 | export function checksum(content: string): string { |
| 19 | let hash = 0x811c9dc5 |
nothing calls this directly
no outgoing calls
no test coverage detected