1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-19 05:09:41 +02:00

fix critical issue with backward compatibility (#185)

This commit is contained in:
Nikita Melnikov 2022-04-24 14:11:51 +03:00 committed by GitHub
parent 836aa8985e
commit aaf2644ed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');
}
/**