473,660 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Md5 vs MD5sum

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 = c37a2719bd83ba7 66b29d8f83cee62 58
My program output = w3onGb2DunZrKdj 4PO5iWA==

public string GetMD5Hash( byte[] input_buffer) {
// create implementation of MD5
MD5 md5 = new MD5CryptoServic eProvider();
// get hash
return System.Convert. ToBase64String( md5.ComputeHash (input_buffer)) ;
}
Nov 15 '05 #1
2 26753
chis2k <sf*@sdf.com> 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 = c37a2719bd83ba7 66b29d8f83cee62 58
My program output = w3onGb2DunZrKdj 4PO5iWA==

public string GetMD5Hash( byte[] input_buffer) {
// create implementation of MD5
MD5 md5 = new MD5CryptoServic eProvider();
// 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.FromBas e64String
("w3onGb2DunZrK dj4PO5iWA==");
Console.WriteLi ne (BitConverter.T oString(md5));
}
}

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2
Thanks! That was it!

"Jon Skeet" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@news.microsof t.com...
chis2k <sf*@sdf.com> 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 = c37a2719bd83ba7 66b29d8f83cee62 58
My program output = w3onGb2DunZrKdj 4PO5iWA==

public string GetMD5Hash( byte[] input_buffer) {
// create implementation of MD5
MD5 md5 = new MD5CryptoServic eProvider();
// 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.FromBas e64String
("w3onGb2DunZrK dj4PO5iWA==");
Console.WriteLi ne (BitConverter.T oString(md5));
}
}

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
12253
by: Ola Natvig | last post by:
Hi all Does anyone know of a fast way to calculate checksums for a large file. I need a way to generate ETag keys for a webserver, the ETag of large files are not realy nececary, but it would be nice if I could do it. I'm using the python hash function on the dynamic generated strings (like in page content) but on things like images I use the shutil's copyfileobject function and the hash of a fileobject's hash are it's handlers memmory...
4
2893
by: Ben Rf | last post by:
Hi I'm new to programming and i'd like to write a program that will parse a list produced by md5summer and give me a report in a text file on which md5 sums appear more than once and where they are located. the end end goal is to have a way of finding duplicate files that are scattered across a lan of 4 windows computers. I've dabbled with different languages over the years and i think
5
2418
by: jwb | last post by:
Hello all, I just was wondering if any one knows how to compare compiled VB.NET executables to determine whether or not they are identical. In the dark ages (read: pre-CLR and .NET) one could simply compute the md5sum of a binary and determine if it was identical to another file. However, under the .NET framework, this has changed; building an executable twice will result in two different sums! I need a quick and reliable way to...
1
1823
by: Andrew Chalk | last post by:
I am using VC++ v7.1. Each time that I do a build the md5sum of the resultant DLL is different. Is VC++ embedding a compile-time timestamp in the output file, or what? Many thanks
0
1250
by: Rory Campbell-Lange | last post by:
I'd like to use an md5 function to hash some strings on debian stable/testing (7.3.2). Is it possible to do this? If so, how do I achieve it? Thanks for any help. Rory -- Rory Campbell-Lange <rory@campbell-lange.net> <www.campbell-lange.net>
3
4132
by: Gary Townsend | last post by:
Hey all i am looking to see if anyone has created a function or knows how to create an md5sum that would match the md5sum routines found commonly in C++ and Linux. Gary Townsend
2
1864
by: intrader | last post by:
I have a .NET interop assembly Hash.MD5Sum with two methods Identity and GetMD5Sum. I want to call the methods from ASP (JScript), The debugger tells me that object oMD5Sum has only one method (ToString()). How do I get the Identity and GetMD5Sum methods to be accessible? I include the entire .net assembley followed by a snippet of the ASP code. /////The code of the .NET assembly is: using System;
1
2414
by: Theadmin77 | last post by:
I know this is a stupid question but ....im stuck ... I have 2 files were i have to perform a md5sum check , the results (hash string) output to a file were must be stamped with the date and time the validation was performed . I got the first part : md5sum file a file b > results.txt But how do you stamp those files with the time and date ?? Any help will be appreciated
4
5142
by: Udai Kiran | last post by:
Hi all, I have been looking for a c function that can calculate md5sum of file given the path of the file. I know that the md5sum utility is included in gnu coreutils. but how can I use this as a function. Is there any library that can do this for me. Thanks in advance. udai. http://s.udaykiran.googlepages.com/
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8754
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.