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

Function encrypt

packages/shared/src/crypto.ts:18–28  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

16};
17
18export function encrypt(text: string): { iv: string; encryptedData: string } {
19 const encryptionKey = Buffer.from(env.SOURCEBOT_ENCRYPTION_KEY, 'ascii');
20
21 const iv = generateIV();
22 const cipher = crypto.createCipheriv(algorithm, encryptionKey, iv);
23
24 let encrypted = cipher.update(text, 'utf8', 'hex');
25 encrypted += cipher.final('hex');
26
27 return { iv: iv.toString('hex'), encryptedData: encrypted };
28}
29
30export function decrypt(iv: string, encryptedText: string): string {
31 const encryptionKey = Buffer.from(env.SOURCEBOT_ENCRYPTION_KEY, 'ascii');

Callers 1

encryptActivationCodeFunction · 0.85

Calls 1

generateIVFunction · 0.85

Tested by

no test coverage detected