为什么C#sha512哈希值与PHP crypt方法不同?

问题描述 投票:-1回答:1

我使用相同的salt和密码,但在C#和PHP中哈希值不同。这是为什么?

string password = "password";
string salt = "salt";

C# :

HMACSHA512 hmac = new HMACSHA512(Encoding.UTF8.GetBytes(salt));

        byte[] bithash = Encoding.UTF8.GetBytes(password);

        for (int i = 0; i < 7778;i++){
            bithash = hmac.ComputeHash(bithash);
        }

        Console.WriteLine( Convert.ToBase64String(bithash) );

uQobtR+v8PovsSOjCZ9tZyOsfUYWw+xZSOMEuljCzXdezVs8LiM85I1JRQsVpKGSalrC5xTu5sU2f127Bw3DoA==

PHP:

crypt('password','$6$rounds=7778$salt$'); 

QVysRURDsOGt7/ig9jE7JNutVD2XWO5h9gmBmvC5HtEUFUtVNugF3GWJe6CwFkVNq91kJY8yL5QVPQYXUzhoM1
c# php crypt sha512
1个回答
0
投票

最后我找到了一个带库的方法:qazxsw poi

https://www.zer7.com/software.php?page=cryptsharp
© www.soinside.com 2019 - 2024. All rights reserved.