/// <summary>
 /// 计算数据的MD5值,以16进制字符串表示结果
 /// </summary>
 /// <param name="data">数据字节数组</param>
 /// <param name="offset">字节数组中的偏移量,从该位置开始使用数据</param>
 /// <param name="count">数组中用作数据的字节数</param>
 /// <returns>以16进制字符串表示的MD5值</returns>
 public static string HashToMD5Hex(this byte[] data, int offset, int count)
 {
     using (MD5CryptoServiceProvider md5sp = new MD5CryptoServiceProvider())
     {
         return(StringEncode.ByteArrayToHexString(md5sp.ComputeHash(data, offset, count)));
     }
 }
Example #2
0
 /// <summary>
 /// 指定编码字符串计算SHA1值(十六进制编码字符串)
 /// </summary>
 /// <param name="sourceStr">指定编码的字符串</param>
 /// <param name="theEncodeing">指定编码格式</param>
 /// <returns>SHA1(十六进制编码字符串)</returns>
 public static string HashToSHA1Hex(this string sourceStr, Encoding theEncodeing)
 {
     return(StringEncode.ByteArrayToHexString(HashToSHA1(sourceStr, theEncodeing)));
 }
Example #3
0
 /// <summary>
 /// 系统默认编码字符串计算SHA1值(十六进制编码字符串)
 /// </summary>
 /// <param name="sourceStr">系统默认编码的字符串</param>
 /// <returns>SHA1(十六进制编码字符串)</returns>
 public static string HashDefaultToSHA1Hex(this string sourceStr)
 {
     return(StringEncode.ByteArrayToHexString(HashDefaultToSHA1(sourceStr)));
 }
Example #4
0
 /// <summary>
 /// UTF8编码字符串计算MD5值(十六进制编码字符串)
 /// </summary>
 /// <param name="sourceStr">UTF8编码的字符串</param>
 /// <returns>MD5(十六进制编码字符串)</returns>
 public static string HashToMD5Hex(this string sourceStr)
 {
     return(StringEncode.ByteArrayToHexString(HashToMD5(sourceStr)));
 }