login about faq

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.

asked Jun 11 '13 at 14:02

rania's gravatar image

rania
45182228


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.

link

answered Jun 12 '13 at 14:39

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×26

Asked: Jun 11 '13 at 14:02

Seen: 1,347 times

Last updated: Jun 12 '13 at 14:39

powered by OSQA