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