怎么可能?我写了一个非常简单的测试来演示它:
vector<char> hash(SHA256_DIGEST_LENGTH);
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", strlen("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"));
SHA256_Final(reinterpret_cast<unsigned char *>(hash.data()), &sha256);
在Windows 7 x64上,哈希值为cf5b16a7 78af8380 036ce59e 7b049237 0b249b11 e8f07a51 afac4503 7afee9d1
。这是正确的。
在Windows 10 x64 Corporate上以某种方式,哈希为23d7f2dc 23d7f2dc e9af6f64 e9af6f64 5542bb78 23d7f2dc e8e3a3d6 e9af6f64
!
为什么Windows 10上的OpenSSL会提供不同的(和错误的)哈希版本?