using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace uploader { internal class Utils { public static string GetMD5(string file) { using (var md5 = MD5.Create()) { using (var stream = File.OpenRead(file)) { var hashBytes = md5.ComputeHash(stream); var sb = new StringBuilder(); foreach (var t in hashBytes) { sb.Append(t.ToString("X2")); } return sb.ToString(); } } } public static string GetSHA256(string file) { using (var stream = File.OpenRead(file)) { var sha = new SHA256Managed(); var checksum = sha.ComputeHash(stream); return BitConverter.ToString(checksum).Replace("-", string.Empty); } } public static string GetSHA1(string file) { using (var stream = File.OpenRead(file)) { var sha = new SHA1Managed(); var checksum = sha.ComputeHash(stream); return BitConverter.ToString(checksum).Replace("-", string.Empty); } } } }