MD5 expert, help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm using the following code snippet kindly provided by one of you guys a
couple of days ago.

using ( FileStream fs = System.IO.File.OpenRead(@"C:\x3.zip") )
{
MD5 m5 = MD5.Create();
byte[] hash = m5.ComputeHash(fs);
string base64Hash = Convert.ToBase64String(hash);
Console.WriteLine(base64Hash);
}

No matter the size of the file I'm hashing with MD5, the last to characters
always seems to bee == as in the hash table below. The

hmFlGc4cdHOx2dHDs7QB6Q==

Why's that?
Thanks, Jesper.
 
=?Utf-8?B?SmVzcGVy?= said:
No matter the size of the file I'm hashing with MD5, the last to
characters always seems to bee == as in the hash table below. The

hmFlGc4cdHOx2dHDs7QB6Q==

This is normal. It has to do with padding the encoding to a certain length when you convert it to base 64.
What you are seeing is not the hash value, but a base 64 encoding of it.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 
Back
Top