日期:2014-05-17 浏览次数:20734 次
//方法一:
public static string GETSHA512Encrypt(string strDigestStr)
{
byte[] aryEncodedData;
SHA512Managed inDigest = new SHA512Managed();
UTF8Encoding inUTF8 = new UTF8Encoding();
aryEncodedData = inUTF8.GetBytes(strDigestStr);
aryEncodedData = inDigest.ComputeHash(aryEncodedData);
String tmp = "";
for (int nLoop = 0; nLoop < aryEncodedData.Length; nLoop++)
tmp += aryEncodedData[nLoop].ToString("X2");
return tmp;
}
//方法二:
public static string SHA512Encrypt(string str)
{
System.Security.Cryptography.SHA512 s512 = new System.Security.Cryptography.SHA512Managed();
byte[] byte1;
byte1 = s512.ComputeHash(Encoding.Default.GetBytes(str));
s512.Clear();
return Convert.ToBase64String(byte1);
}
//方法三: 就在一上面 把 tmp += aryEncodedData[nLoop].ToString("X2"); 改成
tmp += aryEncodedData[nLoop].ToString("");