public string CalculateMD5Unicode(string input)
{
// step 1, calculate MD5 hash from input
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.Unicode.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
return Convert.ToBase64String(hash);
}
Now I need to duplicate the output of this code in Javascript. So far, I've gotten it to where the same bytes are extracted:
function Process(str)
{
var ch;
var bytes = [];
for(var i = 0; i < str.length; i++)
{
ch = str.charCodeAt(i);
bytes.push(ch & 0xFF, ch>>>8);
}
}
But I've hit a bit of a snag in trying to get the MD5 values to match. Specifically, this will be called from an HTML form to generate the same data currently being generated in the compiled C# program.
And yes, I know MD5 hashing is not terribly secure for doing passwords and what-not, but this is only going to be used until this gets closer to being released. Taking a lot of work to convince the guys in charge to buy an SSL certificate as they don't see it as being needed for testing. Isn't it fun to work for people who just don't know how to do...well anything