i have implement a sha1 hash function. The hash function is printing out the hash value correctly but is not storing the hash value correctly to the int variable. Please help me out, i have been trying for the whole day, but im not able to correct the mistake. Thank you for the help.
This is the function
void hashSentence1(string Message1)
{
//sha1 hash is 20 bytes
unsigned char hash[20];
unsigned int ihexvalue;
stringstream str;
// compute the sha1 of the input, and store it our hash array
SHA1((unsigned char*)Message1.c_str(), Message1.size(), hash);
// convert the hash array to hexadecimal values and print out
cout << "Hash of first message was: ";
for(int i = 0; i < 20; ++i)
{
cout << hex << (int)hash[i];
str << hex << (int)hash[i];
str >> ihexvalue;
}
cout << endl << "ihexvalue " << ihexvalue;
cout << endl << endl;
}
This is the output, The int variable should have the same value as the sha1
Message to be hash edbfbeabc123
sha1 - > df7dd80ba924cdef4421d4d73b26323793e24df
ihexvalue -> df