繁体   English   中英

C# 中的密码哈希 sha256

[英]password hashing sha256 in c#

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

我曾经像这样解决过这个问题))。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM