密码加密在C#中? [英] Password encryption in C#?

查看:174
本文介绍了密码加密在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在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 。实现它几乎是微不足道的,它管理所有令人不快的关于userid,密码,登录,注销和更多的批次

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.

这篇关于密码加密在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆