Password encryption in C#?(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.
更好的是,了解内置的 Membership 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.
这篇关于C#中的密码加密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C#中的密码加密?
基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
