(text: string)
| 16 | }; |
| 17 | |
| 18 | export 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 | |
| 30 | export function decrypt(iv: string, encryptedText: string): string { |
| 31 | const encryptionKey = Buffer.from(env.SOURCEBOT_ENCRYPTION_KEY, 'ascii'); |
no test coverage detected