I'm currently using PHP-PACK in Nodejs
But unfortunately, it does not work on windows
so does anyone know a js code has the same functionality as
pack('H*', md5('password')
I tried this code from this reference but doesn't help resolve the issue
String.prototype.packHex = function () {
var source = this.length % 2 ? this + '0' : this
var result = ''
for (var i = 0; i < source.length; i = i + 3) {
result += String.fromCharCode(parseInt(source.substr(i, 2), 16))
}
return result
}
console.log('Pack-hex: --->', Buffer.from(md5('password').packHex()))
console.log('php-pack: --->', Buffer.from(pack('H*', md5('password'))))
result:
Pack-hex: ---> X8OcO8KqZWHCg33CuCzCmQ==
php-pack: ---> X03MO1qnZdYdgyfeuILPmQ==
Thanks for your help