sha256 hash module for file hashes

This commit is contained in:
2025-03-08 02:10:31 -05:00
parent 3aaedf1e8b
commit 384e70e286

11
src/rt/rfwfs/hash.ts Normal file
View File

@ -0,0 +1,11 @@
async function hash(inner_as_string: string) {
const encoder = new TextEncoder()
const hash = await crypto.subtle.digest("SHA-256", encoder.encode(inner_as_string))
const hash_as_uint8 = new Uint8Array(hash)
return Array.from(hash_as_uint8).map(byte => byte.toString(16).padStart(2, "0")).join("")
}
export default async function generate_sha256(inner_as_string: string) {
const sha256 = await hash(inner_as_string)
return sha256
}