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. 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)).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.