Why isn't my PHP SHA256 hash equivalent to C# SHA256Managed hash

后端 未结 6 2119
灰色年华
灰色年华 2020-12-20 12:14

Why aren\'t these the same?

php:

    $hash = hash(\'sha256\', $userData[\'salt\'] . hash(\'sha256\', $password) );

c#



        
6条回答
  •  难免孤独
    2020-12-20 12:23

    Well I'm no C# programmer, but one thing that leaps out at me is this:

    // Convert result into a base64-encoded string.
    string hashValue = Convert.ToBase64String(tHashBytes);
    

    Are you base64-encoding the final output in C#? Because you're not in PHP...

提交回复
热议问题