为什么这些不一样?
原文链接:https://www.f2er.com/php/131834.htmlPHP:
$hash = hash('sha256',$userData['salt'] . hash('sha256',$password) );
C#
public static string ComputeHash(string plainText,string salt) { // Convert plain text into a byte array. byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText); byte[] saltBytes = Encoding.UTF8.GetBytes(salt); SHA256Managed hash = new SHA256Managed(); // Compute hash value of salt. byte[] plainHash = hash.ComputeHash(plainTextBytes); byte[] concat = new byte[plainHash.Length + saltBytes.Length]; System.Buffer.BlockCopy(saltBytes,concat,saltBytes.Length); System.Buffer.BlockCopy(plainHash,saltBytes.Length,plainHash.Length); byte[] tHashBytes = hash.ComputeHash(concat); // Convert result into a base64-encoded string. string hashValue = Convert.ToBase64String(tHashBytes); // Return the result. return hashValue; }