MCPcopy Index your code
hub / github.com/chartbrew/chartbrew / encrypt

Function encrypt

server/modules/cbCrypto.js:8–18  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

6const IV_LENGTH = 16; // AES block size in bytes
7
8function encrypt(text) {
9 // console.log("text", text);
10 if (!text) return text;
11 const iv = crypto.randomBytes(IV_LENGTH);
12 const cipher = crypto.createCipheriv(ALGORITHM, Buffer.from(SECRET_KEY, "hex"), iv);
13 let encrypted = cipher.update(text);
14
15 encrypted = Buffer.concat([encrypted, cipher.final()]);
16
17 return `${iv.toString("hex")}:${encrypted.toString("hex")}`;
18}
19
20function decrypt(text) {
21 if (!text) return text;

Callers 3

encryptFileFunction · 0.70
requestPasswordResetMethod · 0.50

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected