/// <summary>
        /// 获取字节数组的MD5哈希值
        /// </summary>
        public static string GetMd5(this byte[] bytes)
        {
            //bytes.CheckNotNullOrEmpty("bytes");
            StringBuilder sb = new StringBuilder();

            Security.Cryptography.MD5 hash = new Security.Cryptography.MD5CryptoServiceProvider();
            bytes = hash.ComputeHash(bytes);
            foreach (byte b in bytes)
            {
                sb.AppendFormat("{0:x2}", b);
            }
            return(sb.ToString());
        }
예제 #2
0
 public static byte[] ComputeMD5(this Stream stream)
 {
     using var md5 = new Security.Cryptography.MD5CryptoServiceProvider();
     return(md5.ComputeHash(stream));
 }