From 0a793d0c475a121326e6d46c8a89ccbae0be00c8 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 16 Oct 2017 23:18:43 -0400 Subject: [PATCH] fixed encryption --- services/change_password.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/change_password.js b/services/change_password.js index 7157318db..73188e384 100644 --- a/services/change_password.js +++ b/services/change_password.js @@ -30,11 +30,13 @@ async function changePassword(currentPassword, newPassword, req = null) { function encrypt(plainText) { const aes = getAes(newPasswordEncryptionKey); - const digest = crypto.createHash('sha256').update(aesjs.utils.utf8.toBytes(plainText)).digest().slice(0, 4); + const plainTextBuffer = Buffer.from(plainText, 'latin1'); + + const digest = crypto.createHash('sha256').update(plainTextBuffer).digest().slice(0, 4); console.log("Digest:", digest); - const encryptedBytes = aes.encrypt(Buffer.concat([digest, aesjs.utils.utf8.toBytes(plainText)])); + const encryptedBytes = aes.encrypt(Buffer.concat([digest, plainTextBuffer])); console.log("Encrypted", encryptedBytes);