using System.IO; using System.Security.Cryptography;
public static class Algorithms { public static readonly HashAlgorithm MD5 = new MD5CryptoServiceProvider(); } public static string GetChecksum(string filePath, HashAlgorithm algorithm) { using (var stream = new BufferedStream(File.OpenRead(filePath), 100000)) { byte[] hash = algorithm.ComputeHash(stream); return BitConverter.ToString(hash).Replace("-", String.Empty); } }
string path = @"C:\Folder\file.txt"; string checksumMd5 = GetChecksum(path, Algorithms.MD5);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)