MCPcopy Create free account
hub / github.com/chronark/envshare / decrypt

Function decrypt

pkg/encryption.ts:36–51  ·  view source on GitHub ↗
(encrypted: string, keyData: Uint8Array, iv: string, keyVersion: number)

Source from the content-addressed store, hash-verified

34}
35
36export async function decrypt(encrypted: string, keyData: Uint8Array, iv: string, keyVersion: number): Promise<string> {
37 const algorithm = keyVersion === 1 ? "AES-CBC" : "AES-GCM";
38
39 const key = await crypto.subtle.importKey("raw", keyData, { name: algorithm, length: 128 }, false, ["decrypt"]);
40
41 const decrypted = await crypto.subtle.decrypt(
42 {
43 name: algorithm,
44 iv: fromBase58(iv),
45 },
46 key,
47 fromBase58(encrypted),
48 );
49
50 return new TextDecoder().decode(decrypted);
51}

Callers 2

encryption.test.tsFile · 0.90
onSubmitFunction · 0.90

Calls 1

fromBase58Function · 0.90

Tested by

no test coverage detected