Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 什么是asp.net 4中的算法或函数哈希密码?_C#_Asp.net_Asp.net Membership - Fatal编程技术网

C# 什么是asp.net 4中的算法或函数哈希密码?

C# 什么是asp.net 4中的算法或函数哈希密码?,c#,asp.net,asp.net-membership,C#,Asp.net,Asp.net Membership,我想为我的网站创建自定义成员资格,但我不想使用ASP.NET成员资格 我想在自定义成员身份中使用哈希密码,类似于ASP.NET成员身份中的哈希密码 以下代码是否正确且最佳 public string EncodePassword(string pass, string salt) { byte[] bytes = Encoding.Unicode.GetBytes(pass); byte[] src = Encoding.Unicode.GetBytes(salt); b

我想为我的网站创建自定义成员资格,但我不想使用ASP.NET成员资格

我想在自定义成员身份中使用哈希密码,类似于ASP.NET成员身份中的哈希密码

以下代码是否正确且最佳

public string EncodePassword(string pass, string salt)
{
    byte[] bytes = Encoding.Unicode.GetBytes(pass);
    byte[] src = Encoding.Unicode.GetBytes(salt);
    byte[] dst = new byte[src.Length + bytes.Length];

    Buffer.BlockCopy(src, 0, dst, 0, src.Length);
    Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);

    HashAlgorithm algorithm = HashAlgorithm.Create("SHA1");
    byte[] inArray = algorithm.ComputeHash(dst);

    return Convert.ToBase64String(inArray);
}

如果sha1仍然可靠的话,这可能是真的。但是sha1不再可靠了。@JoelCoehoorn请帮助我,因为算法是可靠的。这里也有同样的问题,那个代码不再有效