PC Review


Reply
Thread Tools Rate Thread

C# Md5 vs MD5sum

 
 
chis2k
Guest
Posts: n/a
 
      25th Jul 2003
I am trying to figure out how to get the MD5 sum of a file that is like the
result from the MD5sum.exe program that is readily available on the
internet. I tried the following but it gives me something completely
different.... Any ideas?

MD5sum.exe output = c37a2719bd83ba766b29d8f83cee6258
My program output = w3onGb2DunZrKdj4PO5iWA==

public string GetMD5Hash( byte[] input_buffer) {
// create implementation of MD5
MD5 md5 = new MD5CryptoServiceProvider();
// get hash
return System.Convert.ToBase64String(md5.ComputeHash(input_buffer));
}


 
Reply With Quote
 
 
 
 
Jon Skeet
Guest
Posts: n/a
 
      25th Jul 2003
chis2k <(E-Mail Removed)> wrote:
> I am trying to figure out how to get the MD5 sum of a file that is like the
> result from the MD5sum.exe program that is readily available on the
> internet. I tried the following but it gives me something completely
> different.... Any ideas?
>
> MD5sum.exe output = c37a2719bd83ba766b29d8f83cee6258
> My program output = w3onGb2DunZrKdj4PO5iWA==
>
> public string GetMD5Hash( byte[] input_buffer) {
> // create implementation of MD5
> MD5 md5 = new MD5CryptoServiceProvider();
> // get hash
> return System.Convert.ToBase64String(md5.ComputeHash(input_buffer));
> }


You're assuming that the result of MD5sum is the Base64 result - it
looks more like hex to me. Indeed, if you try the following program
which converts your base64 to hex, you'll see a familiar sequence...

using System;

public class Test
{
static void Main()
{
byte[] md5 = Convert.FromBase64String
("w3onGb2DunZrKdj4PO5iWA==");
Console.WriteLine (BitConverter.ToString(md5));
}
}

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
 
Reply With Quote
 
chis2k
Guest
Posts: n/a
 
      25th Jul 2003
Thanks! That was it!

"Jon Skeet" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> chis2k <(E-Mail Removed)> wrote:
> > I am trying to figure out how to get the MD5 sum of a file that is like

the
> > result from the MD5sum.exe program that is readily available on the
> > internet. I tried the following but it gives me something completely
> > different.... Any ideas?
> >
> > MD5sum.exe output = c37a2719bd83ba766b29d8f83cee6258
> > My program output = w3onGb2DunZrKdj4PO5iWA==
> >
> > public string GetMD5Hash( byte[] input_buffer) {
> > // create implementation of MD5
> > MD5 md5 = new MD5CryptoServiceProvider();
> > // get hash
> > return System.Convert.ToBase64String(md5.ComputeHash(input_buffer));
> > }

>
> You're assuming that the result of MD5sum is the Base64 result - it
> looks more like hex to me. Indeed, if you try the following program
> which converts your base64 to hex, you'll see a familiar sequence...
>
> using System;
>
> public class Test
> {
> static void Main()
> {
> byte[] md5 = Convert.FromBase64String
> ("w3onGb2DunZrKdj4PO5iWA==");
> Console.WriteLine (BitConverter.ToString(md5));
> }
> }
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet/
> If replying to the group, please do not mail me too



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
md5sum for vb net Gary Townsend Microsoft VB .NET 3 8th Oct 2005 12:13 AM
MD5Sum function Gary Townsend Microsoft ADO .NET 2 6th Oct 2005 01:21 AM
How do I check md5sum with XP? RobW Windows XP General 4 23rd Jan 2005 04:50 AM
PW ISO md5sum Mark Carter Freeware 2 23rd Apr 2004 09:31 PM
PW ISO md5sum (Python) Mark Carter Freeware 0 22nd Apr 2004 01:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:41 AM.