Created
February 3, 2018 22:28
-
-
Save sebingel/a3799a9f704752f757c054cbfbe9e31e to your computer and use it in GitHub Desktop.
MD5 Hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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