Skip to content

Commit

Permalink
Replace md5 with sha256 to work on FIPS machines (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianrgreco authored Aug 16, 2024
1 parent 1947842 commit 698241a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/testcontainers/src/common/hash.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { hash } from "./hash";

test("should return a hash", () => {
test("should return a consistent hash", () => {
const str = "Hello, world!";

expect(hash(str)).toBe("6cd3556deb0da54bca060b4c39479839");
expect(hash(str)).toBe("6cd3556deb0da54bca060b4c39479839");
expect(hash(str)).toBe("315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3");
expect(hash(str)).toBe("315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3");
});
2 changes: 1 addition & 1 deletion packages/testcontainers/src/common/hash.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crypto from "crypto";

export function hash(str: string): string {
return crypto.createHash("md5").update(str).digest("hex");
return crypto.createHash("sha256").update(str).digest("hex");
}

0 comments on commit 698241a

Please sign in to comment.