0

I am trying to convert following C# code into 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);
        }

is there any option for above code in C++

  • 3
    *"I am trying"* - perhaps you'd care to show your effort so far, and say where you're stuck? – Tony Delroy Mar 29 '16 at 07:39
  • The C# code uses the .NET Base Class Library. Do you want to write a .NET application using C++? You can do that using [managed C++/CLI](https://en.wikipedia.org/wiki/C%2B%2B/CLI) which is a language based on C++. However, I suspect that you want to implement an unmanaged application (no .NET). In that case you can use [Windows CryptoAPI](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380255(v=vs.85).aspx). – Martin Liversage Mar 29 '16 at 07:49

1 Answers1

1

Try having a look at the free Crypto++ library. It implements several cryptographic algorithms, including SHA256 and AES/Rijndael.

Check the following discussions for examples on how to create SHA256 hashes and decrypt AES:

Create a SHA256 hash with Crypto++

Using AES with Crypto++

Community
  • 1
  • 1