在C#中的密码加密?密码

2023-09-04 00:27:47 作者:与可爱私奔

我怎样才能加密和解密密码,在C#中?感谢您的帮助。

How can I encrypt and decrypt passwords in C#? Thanks for any help.

推荐答案

首先,你不是真的要保存加密密码的任何地方,而你执行单向散列(如的 SHA )存储哈希值。然后,当你质疑他的密码的用户,执行相同的哈希值。如果新的哈希存储的散列相匹配,你已经有了一个匹配。

First, you're not actually going to save the encrypted password anywhere, rather you'd perform a one-way hash (e.g., SHA) store that hash. Then when you challenge a user for his password, you perform the same hash. If the new hash matches the stored hash, you've got a match.

散列和加密之间的区别在于加密,可以恢复原来的文本,其中与哈希你不能。

The difference between a hash and encryption is that with encryption, you can recover the original text, where with a hash you cannot.

阅读上SHA(安全散列算法)等散列算法。这应该给你一个良好的开端。

Read up on SHA (Secure Hashing Algorithm) and other hashing algorithms. This should give you a good start.

更妙的是,了解建于成员身份API 研究。净。这几乎是微不足道的实施并管理所有的不愉快有关用户ID的,密码,登录,注销和很多的更适合你。

Even better, learn about the built in Membership API in .NET. It's almost trivial to implement and it manages all that unpleasantness about userid's, passwords, logging in, logging out and a lot more for you.