We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 543383d commit 6aadad2Copy full SHA for 6aadad2
tests/password.test.ts
@@ -0,0 +1,18 @@
1
+import { describe, expect, test } from "bun:test";
2
+import { createHash } from "node:crypto";
3
+
4
+function hashPassword(pw: string): string {
5
+ return createHash("sha256").update(pw).digest("hex");
6
+}
7
8
+describe("Password hash properties", () => {
9
+ test("hash length is always 64", () => {
10
+ for (const pw of ["a", "password", "x".repeat(1000)]) {
11
+ expect(hashPassword(pw).length).toBe(64);
12
+ }
13
+ });
14
15
+ test("empty vs non-empty produce different hashes", () => {
16
+ expect(hashPassword("")).not.toBe(hashPassword("a"));
17
18
+});
0 commit comments