Trying to reproduce a javascript b64_md5 function with PHP, but results differ

  base64, javascript, md5, php

I am trying to tap into an existing web application that uses the b64_md5 js function to encrypt a password before sending it to the server for security purposes. My script uses PHP and PHP Curl, but I can’t seem to get the same result using php and the same inputs.

Here is the JS that generates the encrypted password using the following script:
https://gist.githubusercontent.com/romeoh/3302246/raw/5fa924ca5ec39b0c3607441d0c077566f36005bc/md5.js

var PasswordMD5 = encodeURIComponent(b64_md5("[email protected]"));

That function returns:
HRQghiCMPfmGHJ67byxCjg==

I’m trying to match that result using PHP. Here is what I’ve got, but it’s not generating a matching result.

<?
$passwordMD5 = base64_encode(md5("[email protected]"));
echo $passwordMD5;
?>

That function returns:
MWQxNDIwODYyMDhjM2RmOTg2MWM5ZWJiNmYyYzQyOGU=

Are there any md5/encoding gurus out there that can help me figure this out?

Source: Ask PHP

LEAVE A COMMENT