(cipher_alg, key, iv, text)
| 1356 | |
| 1357 | // to encrypt data |
| 1358 | function encryptText(cipher_alg, key, iv, text) { |
| 1359 | const cipher = crypto.createCipheriv(cipher_alg, key.toString('hex').slice(0, 32), iv.toString('hex').slice(0, 16)); |
| 1360 | let result = cipher.update(text, 'utf8', 'hex'); |
| 1361 | result += cipher.final('hex'); |
| 1362 | return result; |
| 1363 | } |
| 1364 | |
| 1365 | // to decrypt data |
| 1366 | // eslint-disable-next-line |