
如何使用C#的SHA1对字符串加密?
加密后的字符串结果大概是这种格式的(数字加字母):a08745ab6a6fe4e2bf51fa242375c52639376453...
加密后的字符串结果大概是这种格式的(数字加字母):a08745ab6a6fe4e2bf51fa242375c52639376453
展开
1个回答
展开全部
private static string SHA1(string text)
{
byte[] cleanBytes = Encoding.Default.GetBytes(text);
byte[] hashedBytes = System.Security.Cryptography.SHA1.Create().ComputeHash(cleanBytes);
return BitConverter.ToString(hashedBytes).Replace("-", "");
}
调用这个函数就可以得到你要的sha1值了。
另外还有个概念要澄清,SHA1是散列算法,不是加密。
{
byte[] cleanBytes = Encoding.Default.GetBytes(text);
byte[] hashedBytes = System.Security.Cryptography.SHA1.Create().ComputeHash(cleanBytes);
return BitConverter.ToString(hashedBytes).Replace("-", "");
}
调用这个函数就可以得到你要的sha1值了。
另外还有个概念要澄清,SHA1是散列算法,不是加密。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询