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.
2022-02-24 20:37:40 +00:00
|
|
|
import crypto from "crypto";
|
2022-03-02 18:35:31 +00:00
|
|
|
import * as core from "webcrypto-core";
|
2022-02-24 20:37:40 +00:00
|
|
|
|
|
|
|
export class ShakeCrypto {
|
|
|
|
|
2022-03-02 18:35:31 +00:00
|
|
|
public static digest(algorithm: Required<core.ShakeParams>, data: ArrayBuffer) {
|
|
|
|
const hash = crypto.createHash(algorithm.name.toLowerCase(), {outputLength: algorithm.length})
|
2022-02-24 20:37:40 +00:00
|
|
|
.update(Buffer.from(data)).digest();
|
2022-03-02 18:35:31 +00:00
|
|
|
|
2022-02-24 20:37:40 +00:00
|
|
|
return new Uint8Array(hash).buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|