(text: string)
| 325 | const cipher = crypto.createCipheriv("aes-256-cbc", Buffer.from(ENCRYPTION_KEY), iv); |
| 326 | const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); |
| 327 | return iv.toString("hex") + ":" + encrypted.toString("hex"); |
| 328 | } |
| 329 | |
| 330 | function decrypt(text: string): string { |
| 331 | try { |
| 332 | const textParts = text.split(":"); |
| 333 | const iv = Buffer.from(textParts.shift()!, "hex"); |
| 334 | const encryptedText = Buffer.from(textParts.join(":"), "hex"); |
| 335 | const decipher = crypto.createDecipheriv("aes-256-cbc", Buffer.from(ENCRYPTION_KEY), iv); |
| 336 | return Buffer.concat([decipher.update(encryptedText), decipher.final()]).toString(); |
| 337 | } catch (error: any) { |
| 338 | throw new Error("Failed to decrypt credentials. The key file may have been changed/deleted."); |
| 339 | } |
| 340 | } |
no outgoing calls
no test coverage detected