This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import crypto from "crypto"; | |
| /** Helper function to generate a random salt */ | |
| export function generateSalt(length: number = 32): string { | |
| return crypto.randomBytes(length).toString("hex"); | |
| } | |
| /** Derive a key from a password and salt */ | |
| export function deriveKey(password: string, salt: string): Buffer { | |
| return crypto.pbkdf2Sync(password, salt, 100000, 32, "sha256"); |
NewerOlder