new_10009_YanCheng_Metrology/Assets/Scripts/SecretUtils/Crypto/MD5Util.cs

34 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Security.Cryptography;
namespace SecretUtils.Crypto
{
public class MD5Util
{
public static string GetMD5(byte[] inputBye, string charset)
{
string retStr;
MD5CryptoServiceProvider m5 = new MD5CryptoServiceProvider();
//创建md5对象
//byte[] inputBye;
byte[] outputBye;
////使用GB2312编码方式把字符串转化为字节数组
//try
//{
// inputBye = Encoding.GetEncoding(charset).GetBytes(encypStr);
//}
//catch (Exception ex)
//{
// inputBye = Encoding.GetEncoding("GB2312").GetBytes(encypStr);
// Console.WriteLine(ex);
//}
outputBye = m5.ComputeHash(inputBye);
//retStr= Base64.ToBase64String(outputBye);
retStr = System.BitConverter.ToString(outputBye);
retStr = retStr.Replace("-", "").ToUpper();
return retStr;
}
}
}