I have a javascript function that I am trying to convert to PHP, it uses the CryptoJS library, speciafically components/enc-base64-min.jsand rollups/md5.js. They can be found here .
This is a bit of code
var md5 = CryptoJS.MD5(str);
md5 = md5.toString(CryptoJS.enc.Base64);
I assumed the variable is strhashed using md5, then encoded in Base64, so I tried this simple code
$md5 = md5($str);
$md5 = base64_encode($md5);
// md5 outputs "MmZjMGE0MzNiMjg4MDNlNWI5NzkwNzgyZTRkNzdmMjI="
Then I tried to check both outputs, it looks like JS output is not even a valid Base64 string.
To understand further, I tried to find the parameter toString()from W3Schools , but for me it does not make sense, according to the parameter reference should be an integer (2, 8 or 16), why is it used instead CryptoJS.enc.Base64?
, base64 JS, PHP.