feat: add native KDBX scaffolding and in-memory KeePass API
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { createHash, pbkdf2Sync } from "node:crypto";
|
||||
|
||||
export function sha256(data: Uint8Array | string): Uint8Array {
|
||||
const hash = createHash("sha256");
|
||||
hash.update(data);
|
||||
return new Uint8Array(hash.digest());
|
||||
}
|
||||
|
||||
export function deriveKey(password: string, salt: Uint8Array, rounds: number, length = 32): Uint8Array {
|
||||
if (!Number.isFinite(rounds) || rounds <= 0) {
|
||||
throw new Error("Invalid key derivation rounds");
|
||||
}
|
||||
|
||||
return new Uint8Array(pbkdf2Sync(password, Buffer.from(salt), rounds, length, "sha256"));
|
||||
}
|
||||
Reference in New Issue
Block a user