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:
parent
836aa8985e
commit
aaf2644ed4
1 changed files with 3 additions and 12 deletions
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue