Skip to content

Instantly share code, notes, and snippets.

@sebingel
Created February 3, 2018 22:28
Show Gist options
  • Save sebingel/a3799a9f704752f757c054cbfbe9e31e to your computer and use it in GitHub Desktop.
Save sebingel/a3799a9f704752f757c054cbfbe9e31e to your computer and use it in GitHub Desktop.
MD5 Hash
using (var md5 = System.Security.Cryptography.MD5.Create())
{
using (var stream = File.OpenRead(@"E:\somefile.zip"))
{
Console.WriteLine(BitConverter.ToString(md5.ComputeHash(stream)).Replace("-","‌​").ToLower());
}
}
foreach(var file in new DirectoryInfo(new Uri("file://somepath/").LocalPath).GetFiles().Select(x => x.FullName))
{
Console.WriteLine(file);
using (var stream = File.OpenRead(file))
{
using (var md5 = System.Security.Cryptography.MD5.Create())
{
var computedHash = md5.ComputeHash(stream);
Console.WriteLine(BitConverter.ToString(computedHash).Replace("-", "‌​").ToLower());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment