This repository has been archived on 2023-04-04. You can view files and clone it, but cannot push or open issues or pull requests.
webcrypto/src/mechs/shake/crypto.ts

20 lines
445 B
TypeScript

import { Buffer } from "buffer";
import crypto from "crypto";
import * as core from "webcrypto-core";
export class ShakeCrypto {
public static digest(
algorithm: Required<core.ShakeParams>,
data: ArrayBuffer
) {
const hash = crypto
.createHash(algorithm.name.toLowerCase(), {
outputLength: algorithm.length,
})
.update(Buffer.from(data))
.digest();
return new Uint8Array(hash).buffer;
}
}