代码:
SHA1 sha = new SHA1CryptoServiceProvider();
string hashedValue = string.Empty;
//hash the data
byte[] hashedData = sha.ComputeHash(Encoding.Unicode.GetBytes(str));
//loop through each byte in the byte array
foreach (byte b in hashedData)
{
//convert each byte and append
hashedValue += String.Format("{0,2:X2}", b);
}
我搜索了传递给 String.Format() 的参数,但无法准确理解。
提前致谢!