MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / encrypt

Function encrypt

packages/db/src/encryption.ts:22–33  ·  view source on GitHub ↗
(plaintext: string)

Source from the content-addressed store, hash-verified

20}
21
22export function encrypt(plaintext: string): string {
23 const key = getKey();
24 const iv = randomBytes(IV_LENGTH);
25 const cipher = createCipheriv(ALGORITHM, key, iv);
26 const encrypted = Buffer.concat([
27 cipher.update(plaintext, 'utf8'),
28 cipher.final(),
29 ]);
30 const tag = cipher.getAuthTag();
31 // Format: base64(iv + tag + ciphertext)
32 return Buffer.concat([iv, tag, encrypted]).toString(ENCODING);
33}
34
35export function decrypt(ciphertext: string): string {
36 const key = getKey();

Callers 3

getGscAccessTokenFunction · 0.90
auth.tsFile · 0.90
gscGoogleCallbackFunction · 0.90

Calls 2

getKeyFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected