Question:
Hi,,
I'm trying to perform a hashing algorithm (sha256) on a variable entered by the user called "number". But the problem is: whenever the user enters a different number but with the same number of digits, I get the SAME hash result. for example: when entering 1234567890, I get the same result, as entering 6548932495.
And here is the Hashing function:
const char * Nonce_Hash2(const char * number) { CkCrypt2 crypt1;
bool success;
success = crypt1.UnlockComponent("********************");
if (success != true) {
printf("Crypt component unlock failed\n"); }
crypt1.put_EncodingMode("hex");
const char * hash2;
// Hash using SHA-256
crypt1.put_HashAlgorithm("sha256");
hash2 = crypt1.hashStringENC(number);
printf("\nSHA256:\n");
printf("%s\n",hash2);
return hash2;
}
Can some one please tell me what's the problem with my function! Regards.
I can assure you there is nothing wrong with CkCrypt2::hashStringENC.
Check your input just prior to calling hashStringENC: printf("%sn",number);
Turn on verbose logging (crypt1.put_VerboseLogging(true)) and then examine the crypt1.lastErrorText() after calling hashStringENC.