* Encrypt data for protocol 3.3 and before * @param {Object} options Options for encryption * @param {String} options.data data to encrypt * @param {Boolean} [options.base64=true] `true` to return result in Base64 * @returns {Buffer|String} returns Buffer unless options.base64 is true
(options)
| 52 | * @returns {Buffer|String} returns Buffer unless options.base64 is true |
| 53 | */ |
| 54 | _encryptPre34(options) { |
| 55 | const cipher = crypto.createCipheriv('aes-128-ecb', this.getKey(), ''); |
| 56 | |
| 57 | let encrypted = cipher.update(options.data, 'utf8', 'base64'); |
| 58 | encrypted += cipher.final('base64'); |
| 59 | |
| 60 | // Default base64 enable |
| 61 | if (options.base64 === false) { |
| 62 | return Buffer.from(encrypted, 'base64'); |
| 63 | } |
| 64 | |
| 65 | return encrypted; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Encrypt data for protocol 3.4 |