@xmr-core/xmr-fast-hash
Version:
An implementation of Monero's `cn_fast_hash`
13 lines (10 loc) • 368 B
text/typescript
import { hextobin, valid_hex } from "@xmr-core/xmr-str-utils";
import SHA3 = require("keccakjs");
export function cn_fast_hash(input: string) {
if (input.length % 2 !== 0 || !valid_hex(input)) {
throw Error("Input invalid");
}
const hasher = new SHA3(256);
hasher.update(Buffer.from((hextobin(input).buffer as any) as Buffer));
return hasher.digest("hex");
}