Пример #1
0
        public static string CalculateMD5(this SPath file)
        {
            byte[] computeHash;
            using (var md5 = MD5.Create())
            {
                using (var stream = file.OpenRead())
                {
                    computeHash = md5.ComputeHash(stream);
                }
            }

            return(BitConverter.ToString(computeHash).Replace("-", string.Empty).ToLower());
        }
Пример #2
0
        public static string ToSha256(this SPath path)
        {
            byte[] computeHash;
            using (var hash = System.Security.Cryptography.SHA256.Create())
            {
                using (var stream = path.OpenRead())
                {
                    computeHash = hash.ComputeHash(stream);
                }
            }

            return(BitConverter.ToString(computeHash).Replace("-", string.Empty).ToLower());
        }