As I understand Indy does not directly implement SHA256 and above and I must use OpenSSL.If I use the following I don't get any result:
#include <IdHashSHA.hpp>
...
TIdHashSHA256 *x = new TIdHashSHA256;
ShowMessage(BoolToStr(x->IsAvailable(), true));
i get false. I read somewhere I need to use IdSSLOpenSSLHeaders and load SSL library but I don't know how. Can anyone give an example how to use SHA256 in C++ Builder?
You need to call LoadOpenSSLLibrary()
to initialize the OpenSSL functions that TIdHashSHA256
uses internally.
Also, IsAvailable()
is a class
method (similar to a static
method but with an extra metaclass parameter), so you do not need an object instance to call it:
#include <IdSSLOpenSSLHeaders.hpp>
#include <IdHashSHA.hpp>
...
LoadOpenSSLLibrary(); // <-- add this
// if using CB2007 or earlier:
ShowMessage(BoolToStr(TIdHashSHA256::IsAvailable(__classid(TIdHashSHA256)), true));
// if using CB2009 or later:
ShowMessage(BoolToStr(TIdHashSHA256::IsAvailable(), true));