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 (ethers-io#3082).
  • Loading branch information
ricmoo authored and Woodpile37 committed Jan 14, 2024
1 parent b2e6e2c commit 8a575b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/sha2/src.ts/sha2.ts
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 8a575b1

Please sign in to comment.