MD5 expert, help!

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.
 
C

Chad Z. Hower aka Kudzu

=?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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top