Skip to content

Commit 450694e

Browse files
committedJul 14, 2022
Switch to hash.js for ripemd160 on node as it was removed from the default crypto provider in node 17 (#3082).

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎packages/sha2/src.ts/sha2.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { createHash, createHmac } from "crypto";
44

5+
import hash from "hash.js";
6+
57
import { arrayify, BytesLike } from "@ethersproject/bytes";
68

79
import { SupportedAlgorithm } from "./types";
@@ -11,7 +13,7 @@ import { version } from "./_version";
1113
const logger = new Logger(version);
1214

1315
export function ripemd160(data: BytesLike): string {
14-
return "0x" + createHash("ripemd160").update(Buffer.from(arrayify(data))).digest("hex")
16+
return "0x" + (hash.ripemd160().update(arrayify(data)).digest("hex"));
1517
}
1618

1719
export function sha256(data: BytesLike): string {

0 commit comments

Comments
 (0)
Please sign in to comment.