I have a simple code to create a checksum for files to compare if a file is new or not.
class Program
{
static void Main(string[] args)
{
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead("output_log.txt"))
{
var checksum = BitConverter.ToString(md5.ComputeHash(stream))
.Replace("-", "")
.ToLower();
System.Diagnostics.Debug.WriteLine(checksum);
Console.Write(checksum);
}
}
}
}
Outputs:
Debug.WriteLine :
A4 88 announcements a7 cc db a7 31 25 a9 e0 44 75 44 86 7s
Console.Write
a4 ?? 88 ???? ad a7 ?? cc ?? db ?? a7 ?? 31 ?? 25 ?? a9 ?? e0 ?? 44 ?? 75 ?? 44 ?? 86 ?? 7s
I think the output of the MD5 digest function is a binary sequence of bytes, not a printed string of characters.
How to print md5 digest as human readable representation as result in Debug.WriteLine?
source
share