Skip to content

Commit

Permalink
Switch to hash.js for ripemd160 on node as it was removed from the de…
Browse files Browse the repository at this point in the history
…fault crypto provider in node 17 (#3082).
  • Loading branch information
ricmoo committed Jul 14, 2022
1 parent 4d3e586 commit 450694e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/sha2/src.ts/sha2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { createHash, createHmac } from "crypto";

import hash from "hash.js";

import { arrayify, BytesLike } from "@ethersproject/bytes";

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

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

export function sha256(data: BytesLike): string {
Expand Down

0 comments on commit 450694e

Please sign in to comment.