initial commit with imported utils from old github project

This commit is contained in:
pascalyazid committed 2026-05-10 16:30:28 +02:00
commit 66bb463e23
39 files changed
+1944

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
"use server";
import { subtle } from "crypto";
export async function deriveKey(passphrase: string, salt: Uint8Array) {
const encodedPassword = new TextEncoder().encode(passphrase);
const baseKey = await subtle.importKey(
"raw",
encodedPassword,
{ name: "PBKDF2" },
false,
["deriveKey"],
);
const derivedKey = await subtle.deriveKey(
{
name: "PBKDF2",
salt,
iterations: 600000,
hash: "SHA-256",
},
baseKey,
{ name: "AES-GCM", length: 256 },
true,
["encrypt", "decrypt"],
);
return derivedKey;
}