• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

butlergroup / env_encryption_tool_nodejs / 15961242160

30 Jun 2025 12:44AM UTC coverage: 92.424% (-1.6%) from 94.03%
15961242160

push

github

butlergroup
	modified:   package-lock.json
	modified:   package.json

4 of 7 branches covered (57.14%)

Branch coverage included in aggregate %.

57 of 59 relevant lines covered (96.61%)

12.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/decryptConfig.js
1
const crypto = require('crypto');
12✔
2
const fs = require('fs');
12✔
3
const path = require('path');
12✔
4

12✔
5
module.exports = function decryptConfig() {
12✔
6
    try {
12✔
7
        const algorithm = 'aes-256-gcm';
12✔
8
        const secretKey = process.env.DECRYPTION_KEY;
12✔
9
        const encryptedFilePath = path.join(__dirname, 'env.enc');
12✔
10

12✔
11
        const fileContent = fs.readFileSync(encryptedFilePath, 'utf8');
12✔
12
        const [ivHex, authTagHex, encryptedHex] = fileContent.split(':');
12✔
13

12✔
14
        const iv = Buffer.from(ivHex, 'hex');
12✔
15
        const authTag = Buffer.from(authTagHex, 'hex');
12✔
16
        const encryptedData = Buffer.from(encryptedHex, 'hex');
12✔
17

12✔
18
        const decipher = crypto.createDecipheriv(algorithm, Buffer.from(secretKey, 'utf8'), iv);
12✔
19
        decipher.setAuthTag(authTag);
12✔
20

12✔
21
        const decryptedData = Buffer.concat([decipher.update(encryptedData), decipher.final()]);
12✔
22
        const decryptedString = decryptedData.toString('utf8');
12✔
23

24✔
24
        decryptedString.split('\n').forEach(line => {
24✔
25
            if (line) {
24✔
26
                const [key, ...valueParts] = line.split('=');
24!
27
                let value = valueParts.join('=').trim();
24!
28
                if (value.startsWith('"') && value.endsWith('"')) {
24✔
29
                    value = value.slice(1, -1);
12!
30
                }
×
31
                if (key && value) {
×
32
                    process.env[key.trim()] = value;
12✔
33
                }
12✔
34
            }
12✔
35
        });
12✔
36
    } catch (error) {
12✔
37
        console.error('Error during decryption:', error);
12✔
38
    }
12✔
39
};
12✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc