feat: add native KDBX scaffolding and in-memory KeePass API
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { deriveKey, sha256 } from "../../src/kdbx/crypto";
|
||||
|
||||
describe("kdbx crypto helpers", () => {
|
||||
test("sha256 hashes data deterministically", () => {
|
||||
const digest = sha256("abc");
|
||||
expect(Array.from(digest)).toHaveLength(32);
|
||||
});
|
||||
|
||||
test("deriveKey rejects invalid rounds", () => {
|
||||
expect(() => deriveKey("secret", new Uint8Array([1, 2, 3]), 0)).toThrow("Invalid key derivation rounds");
|
||||
});
|
||||
|
||||
test("deriveKey produces a 32-byte key", () => {
|
||||
const key = deriveKey("secret", new Uint8Array([1, 2, 3]), 1000);
|
||||
expect(Array.from(key)).toHaveLength(32);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user