wynn/ts/src/lib/util/hashers.ts

14 lines
352 B
TypeScript
Raw Normal View History

2025-06-14 23:04:46 +00:00
import crypto from 'node:crypto'
import { type IDataType, xxhash128 } from 'hash-wasm'
2025-02-27 03:56:30 +00:00
export function sha1Hash(data: crypto.BinaryLike) {
2025-06-14 23:04:46 +00:00
const hash = crypto.createHash('sha1')
hash.update(data)
return hash.digest('hex')
2025-02-27 03:56:30 +00:00
}
2025-06-14 23:04:46 +00:00
export async function fastHashFileV1(data: IDataType): Promise<string> {
2025-02-27 03:56:30 +00:00
const hash = xxhash128(data)
return hash
}