initial commit with imported utils from old github project
This commit is contained in:
commit
66bb463e23
39 files changed
+1944
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user