I'm using the CryptoJS library for Javascript MD5 and SHA256 hashing: https://code.google.com/p/crypto-js/
The SHA256 stuff is working fine, but I can't convert the MD5 hash result from a word array back into a string. Below is the code I'm using to just degug the problem - I've subbed out the actual hash results, and added the console.log()
output as comments
email_hash = $rootScope.session.email.toLowerCase();
console.log('email', email_hash);
// email email@example.com
sha_hash = CryptoJS.SHA256(email_hash).toString(CryptoJS.enc.Hex);
console.log('sha', sha_hash);
// sha SHA256-VALUE-OUTPUTS-FINE
email_hash = CryptoJS.MD5( email_hash );
console.log( JSON.stringify( email_hash ) );
//{"words":[0000000000,-0000000000,-00000000000,0000000000],"sigBytes":16}
a = email_hash.toString( CryptoJS.enc.Latin1 );
b = email_hash.toString( CryptoJS.enc.Hex );
console.log( a, b );
// [object Object] [object Object]
What am I doing wrong with the MD5 result?