SHA256 C ++中的哈希计算

时间:2016-03-29 07:30:36

标签: c# c++

我正在尝试将以下C#代码转换为C ++

        SHA256 hash = SHA256.Create();
        hash.TransformBlock(key, 0, key.Length, null, 0);
        for (int i = 0; i < 1000; ++i)
        {
            hash.TransformBlock(cipheredSHA256Hash, 0, 32, null, 0);
        }
        hash.TransformFinalBlock(cipheredSHA256Hash,0, 0);

        using (RijndaelManaged rijndael = new RijndaelManaged())
        {
            rijndael.Key = hash.Hash;
            rijndael.Mode = CipherMode.ECB;
            rijndael.Padding = PaddingMode.Zeros;
            ICryptoTransform decryptor = rijndael.CreateDecryptor();

            return decryptor.TransformFinalBlock(cipheredOffSet60, 0, cipheredOffSet60.Length);
        }

C ++中的上述代码是否有任何选项

1 个答案:

答案 0 :(得分:0)

尝试查看免费的Crypto++库。它实现了几种加密算法,包括SHA256和AES / Rijndael。

请查看以下讨论,了解有关如何创建SHA256哈希值和解密AES的示例:

Create a SHA256 hash with Crypto++

Using AES with Crypto++