I'm migrating from nodejs to PHP and I couldn't obtain a similar output md5 hash digest for the below snippet having the same input.Perhaps there's something I'm missing.
var md5sum = crypto.createHash('md5');
md5sum.update(new Buffer(str, 'binary'));
md5_result = md5sum.digest('hex');
Thanks in advance for your help!!!, Btw, my nodejs version is 10.1.0, and npm version is 5.6.0. And for the ones asking, this source code equivalent is not md5($str)
and it is not my code, I'm just converting it. For example, for the following input 42b86318d761e13ef90c126c3e060582¤3¤724039¤1
the obtained digest is 9860bd2248c069c7b65045917c215596
.
I just tried to run the following snippet at https://www.tutorialspoint.com/execute_nodejs_online.php, taking into account your proposals but they don't work:
const crypto = require('crypto');
var str = "42b86318d761e13ef90c126c3e060582¤3¤724039¤1";
var md5sum = crypto.createHash('md5');
md5sum.update(new Buffer(str, 'binary'));
const md5_result = md5sum.digest('hex');
const md5 = crypto.createHash('md5').update(str).digest('hex');
const expected_digest = "9860bd2248c069c7b65045917c215596";
console.log("original version digest:" + md5_result);
console.log("proposed equivalent digest:" + md5);
console.log("expected digest:" + expected_digest);
What I get on that site is:
original version digest:9860bd2248c069c7b65045917c215596
proposed equivalent digest:b8ee918f782fe7135b25c1fa59339094
expected digest:9860bd2248c069c7b65045917c215596
Other sites such as https://www.katacoda.com/courses/nodejs/playground,https://repl.it/ ,https://www.jdoodle.com/execute-nodejs-online support my claim (i.e. md5 digest is 9860bd2248c069c7b65045917c215596
), however,so far, this site http://rextester.com/l/nodejs_online_compiler outputs what some of you obtained(i.e. b8ee918f782fe7135b25c1fa59339094
). As I said before, please, help me find a PHP EQUIVALENT version of the first nodejs snippet of code.