From aaf2644ed49aad237f0249b4e6a0330dc7d0963f Mon Sep 17 00:00:00 2001 From: Nikita Melnikov Date: Sun, 24 Apr 2022 14:11:51 +0300 Subject: [PATCH] fix critical issue with backward compatibility (#185) --- src/backend/utils/crypto.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/backend/utils/crypto.ts b/src/backend/utils/crypto.ts index 39b60c6..6782a9a 100644 --- a/src/backend/utils/crypto.ts +++ b/src/backend/utils/crypto.ts @@ -1,15 +1,5 @@ import crypto from 'crypto'; -/** - * - * @param {string} hexStr - input hex string - * @returns {string} - output binary string - */ -function hexToBinary(hexStr: string): string { - return (parseInt(hexStr, 16).toString(2)) - .padStart(8, '0'); -} - /** * Create binary md5 * @@ -17,9 +7,10 @@ function hexToBinary(hexStr: string): string { * @returns {string} - binary hash of argument */ export function binaryMD5(stringToHash: string): string { - return hexToBinary(crypto.createHash('md5') + return crypto.createHash('md5') .update(stringToHash) - .digest('hex')); + .digest() + .toString('binary'); } /**