CryptoPP::Integer iRandomValue;
CryptoPP::AutoSeededRandomPool prng;
CryptoPP::SHA1 hash;
std::string digest,tmp;
std::ostringstream ossRandomValue;
//RANDOM VALUE
iRandomValue.Randomize(prng, bitsize);
ossRandomValue << iRandomValue;
tmp=ossRandomValue.str();
std::cout<<"DEC VALUE :"<<std::dec<<iRandomValue<<std::endl;
int i=0;
while(i<2)
{
std::string sHash1;
CryptoPP::HexEncoder hEncoder1(new CryptoPP::StringSink(sHash1));
CryptoPP::StringSource(tmp, true, /*PumpAll*/
new CryptoPP::Redirector(hEncoder1)
);
std::cout<<"ORIGINAL VALUE:"<<tmp<<":"<<std::endl;
std::cout<<"HEX ORIGINAL VALUE:"<<sHash1<<std::endl;
int x=0;
if(i<=0)
x=1;
else
x=0;
hash.Update((const CryptoPP::byte*)sHash1.data(), sHash1.size());
digest.resize(hash.DigestSize());
hash.Final((CryptoPP::byte*)&digest[0]);
CryptoPP::Integer result;
result.Decode((CryptoPP::byte*)&digest[0],hash.DigestSize());
std::ostringstream ossHashDecimal;
ossHashDecimal << result;
tmp=digest;
std::cout<<"HASH VALUE DEC:"<<tmp<<std::endl;
std::string sHash;
CryptoPP::HexEncoder hEncoder(new CryptoPP::StringSink(sHash));
CryptoPP::StringSource(digest, true, /*PumpAll*/
new CryptoPP::Redirector(hEncoder)
);
std::cout<<"HASH VALUE:"<<sHash<<std::endl;
i++;
}