c#中密码哈希sha256



我在vs 2019中创建了一个带有登录系统的WinForms应用程序,现在我想在将其存储在数据库中之前对用户输入的密码进行哈希。但它会存在三个错误:

代码:

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;
}

我曾经这样解决过这个问题

最新更新