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

Function encryptFile

server/modules/fileEncryption.js:11–27  ·  view source on GitHub ↗

* Encrypts a file and replaces the original with the encrypted version * @param {string} filePath - Path to the file to encrypt * @returns {Promise } - Path to the encrypted file

(filePath)

Source from the content-addressed store, hash-verified

9 * @returns {Promise<string>} - Path to the encrypted file
10 */
11async function encryptFile(filePath) {
12 try {
13 // Read the file
14 const fileContent = await fs.readFile(filePath);
15
16 // Encrypt the content
17 const encryptedContent = encrypt(fileContent.toString("base64"));
18
19 // Write the encrypted content back to the file
20 await fs.writeFile(filePath, encryptedContent);
21
22 return filePath;
23 } catch (error) {
24 console.error(`Error encrypting file ${filePath}:`, error); // oxlint-disable-line no-console
25 throw error;
26 }
27}
28
29/**
30 * Decrypts a file and returns the content

Callers 1

ConnectionRoute.jsFile · 0.85

Calls 1

encryptFunction · 0.70

Tested by

no test coverage detected