From 44835f41bd348594cf5f374452c4338c8a3b8f80 Mon Sep 17 00:00:00 2001 From: Kasra Bigdeli Date: Sat, 16 Feb 2019 21:08:41 -0800 Subject: [PATCH] Removed deprecated Buffer constructor --- src/utils/Encryptor.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/Encryptor.ts b/src/utils/Encryptor.ts index 3f27ae2..5973624 100644 --- a/src/utils/Encryptor.ts +++ b/src/utils/Encryptor.ts @@ -30,7 +30,7 @@ export class CaptainEncryptor { const self = this let iv = crypto.randomBytes(IV_LENGTH) - let key = new Buffer(self.encryptionKey) + let key = Buffer.from(self.encryptionKey) let cipher = crypto.createCipheriv(algorithm, key, iv) let encrypted = cipher.update(clearText) @@ -47,9 +47,9 @@ export class CaptainEncryptor { let shifted = textParts.shift() if (!shifted) throw new Error('text.split failed') - let iv = new Buffer(shifted, 'hex') - let encryptedText = new Buffer(textParts.join(':'), 'hex') - let key = new Buffer(self.encryptionKey) + let iv = Buffer.from(shifted, 'hex') + let encryptedText = Buffer.from(textParts.join(':'), 'hex') + let key = Buffer.from(self.encryptionKey) let decipher = crypto.createDecipheriv(algorithm, key, iv) let decrypted = decipher.update(encryptedText)