Sunday, September 9, 2012

Calculate MD5 Hash of a File

In the previous post I explained basics about hashing and hashing of strings, I will start from there on. For that reason I just publish the code which calculates the hash sum of a complete file:

MD5 Md5Hash = MD5.Create();
System.IO.FileStream HashStream = new System.IO.FileStream(@"C:\Users\User\Documents\c#.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] Data = Md5Hash.ComputeHash(HashStream);
string Hash =  System.BitConverter.ToString(Data);

No comments:

Post a Comment