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#中的密码加密?
基础教程推荐
- WPF 模态进度窗口 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
