Manik Taneja wrote:

I am trying to write a hash program which could compute the Hash for all the different types -
SHA1, SHA256, MD5, ....

As such, I wrote the following function that computes the hash for different algorithms

i coded the function as -

void HashDump(CryptoPP::HashTransformation& hash, char const* Module,
std::string const& strData)
{
....
...
....
...


}

However, when I call the function as -

HashDump(SHA(), "SHA 1", strData);

the compiler generates an error saying -

could not convert 'SHA()' to 'CryptoPP::HashTransformation&'

I really wish to figure out which **interface** to use so that I could
just pass the requisite arguments and the function computes the
appropriate hash for me.
I think CryptoPP::HashTransformation is just what you need.
But are you sure that compiler knows what is SHA()?
Maybe you should write CryptoPP::SHA?
A little hint: you can replace the second hard-coded parameter by CryptoPP::SHA::StaticAlgorithmName(), this way you'll get the algorithm name from cryptopp inside. ;) Also you can make a template function that will do the similar job, like this:

template<class HASH>
void HashDump(std::string const& strData)
{
        //get the algorithm name like this:
        char* alg = HASH::StaticAlgorithmName();
}

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Manik Taneja
University at Buffalo
mtaneja [at] buffalo [dot] edu




Reply via email to