[英]password hashing sha256 in c#
I had created a WinForms application with a login system in vs 2019, and now I want to hash the password entered by the user before storing it in the database.我在 vs 2019 中创建了一个带有登录系统的 WinForms 应用程序,现在我想在将用户输入的密码存储到数据库之前对其进行哈希处理。 But it will exist three errors:
但是会存在三个错误:
Code:代码:
public static string getHash(string source)
{
using (SHA256 sha256Hash = SHA256.Create())
{
string hash = getsha256Hash(sha256Hash, source);
return getsha256Hash(sha256Hash, source);
}
}
using System.Security.Cryptography;
using System.Text;
private static string GenerateHash(string toHash)
{
var crypt = new SHA256Managed();
string hash = String.Empty;
byte[] crypto = crypt.ComputeHash(Encoding.ASCII.GetBytes(toHash));
foreach (byte theByte in crypto)
{
hash += theByte.ToString("x2");
}
return hash;
}
I once solved this problem like this)).我曾经像这样解决过这个问题))。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.