c# - 有比 MD5 更好的加密方法吗? (。网)

标签 c# .net asp.net

我正在寻找比 MD5 更好的加密方法。它必须是单向加密,因为我不想在加密中使用 key 。

最佳答案

基本上MD5是哈希算法而不是加密。 你可以使用更稳定的SHA1

using(System.Security.Cryptography.SHA1 hash = System.Security.Cryptography.SHA1.Create())
{ 
   System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();   
   byte[] combined = encoder.GetBytes(str);   
   hash.ComputeHash(combined);   
}

编辑:回复评论

System.Security.Cryptography.SHA1 Class

The hash is used as a unique value of fixed size representing a large amount of data. Hashes of two sets of data should match if the corresponding data also matches. Small changes to the data result in large, unpredictable changes in the hash.

The hash size for the SHA1 algorithm is 160 bits.

关于c# - 有比 MD5 更好的加密方法吗? (。网),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7024365/

相关文章:

c# - 全局抑制 c# 编译器警告

c# - 某些用户的 ASP.NET 转发器控件重叠

asp.net - DELETE 返回错误 405(方法不允许)我正在使用 React 和 ASP.Net Core

c# - 从 C# LINQ 解析 XML 时如何保留空白字符

c# - 如何使用 .NET 的 MongoDB 驱动程序的 updateOne() 更新但不替换文档

c# - Windows 服务无法获得正确的系统文化

Linux 上的 ASP.Net

c# - 无法将对象复制到新数组中

c# - 线程安全是什么意思

c# - 有人可以给我一个如何在 C# 中使用 System.Monitor 的简单示例吗?