(text)
| 18 | } |
| 19 | |
| 20 | function decrypt(text) { |
| 21 | if (!text) return text; |
| 22 | // console.log("text decrypt", text); |
| 23 | |
| 24 | const textParts = text.split(":"); |
| 25 | const iv = Buffer.from(textParts.shift(), "hex"); |
| 26 | const encryptedText = Buffer.from(textParts.join(":"), "hex"); |
| 27 | const decipher = crypto.createDecipheriv(ALGORITHM, Buffer.from(SECRET_KEY, "hex"), iv); |
| 28 | let decrypted = decipher.update(encryptedText); |
| 29 | |
| 30 | decrypted = Buffer.concat([decrypted, decipher.final()]); |
| 31 | |
| 32 | return decrypted.toString(); |
| 33 | } |
| 34 | |
| 35 | function isValidAES256Key(key) { |
| 36 | // Check if the key length is 64 hexadecimal characters (which represents 32 bytes) |
no test coverage detected