Reason For This Howto
As you may know the MD5CryptoService, which the .NET Framework uses, doesn't create an md5 sum's string. So you only have the pure byte[]
which isn't that useful if you want to use it in a database or on your Web Server to compare the sum with your file's sum! So, if many people have no idea how to get their sum into the right way, here's my howto to create the same sums like "md5sum" does:
Code
This is the second version with the Hex-bug fixed.
using System.Security.Cryptography;
.....
.....
string MD5SUM(byte[] FileOrText)
{
return BitConverter.ToString(new
MD5CryptoServiceProvider().ComputeHash(FileOrText)).Replace("-","").ToLower();
}
You can use this example of course for SHA1 as well, just change the MD5CryptoServiceProvider to SHA1CryptoServiceProvider.