@omnimedia/omnitool
Version:
open source video processing tools
20 lines • 615 B
JavaScript
import { hex, thumbprint } from "@e280/stz";
import { blake3 } from "@awasm/noble";
export class Checksum {
hash;
nickname;
constructor(hash, nickname) {
this.hash = hash;
this.nickname = nickname;
}
static async make(file) {
const hasher = blake3.create();
for await (const chunk of file.stream())
hasher.update(chunk);
const digest = hasher.digest();
const hash = hex.fromBytes(digest);
const nickname = thumbprint.sigil.fromBytes(digest);
return new this(hash, nickname);
}
}
//# sourceMappingURL=checksum.js.map