问题描述
在C#中我们如何能够自动使用SHA1?
是SHA1比MD5更好?(我们使用散列的用户名和密码,需要速度认证)
In C# how we can use SHA1 automatically?
Is SHA1 better than MD5?(We use hashing for user name and password and need speed for authentication)
推荐答案
不知道你所说的自动的意思,但你应该使用 SHA256
高。同样的总是 使用的盐(的)与你的哈希值。一个侧面说明,之后,时间已经过去了,采用硬化哈希值远远比使用普通的速度为基础的哈希函数更好。即:散列经过几百次的迭代,或者使用已经证明散列函数,如 bcrypt
(这是下面提到我相信)。在.NET中使用SHA256散列函数code示例如下:
Not sure what you mean by automatically, but you should really use SHA256
and higher. Also always use a Salt (code) with your hashes. A side note, after time has passed, using hardened hashes is far better than using a plain speed-based hashing function. I.e.: hashing over a few hundred iterations, or using already proven hashing functions such as bcrypt
(which is mentioned below I believe). A code sample for using a SHA256 hash function in .NET is as follows:
byte[] data = new byte[DATA_SIZE];
byte[] result;
using(SHA256 shaM = new SHA256Managed()) {
result = shaM.ComputeHash(data);
}
将使用SHA256做的伎俩,为您和发现的MSDN.
旁注上的SHA1的咔:将SHA-1的裂化以透视的
Sidenote on the "cracking" of SHA1: Putting the cracking of SHA-1 in perspective
这篇关于如何使用SHA1或MD5在C#中?(其中一个是在性能和安全性进行验证更好)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!