tags:

views:

534

answers:

3

Hello everyone,

I try to invoke the following code to get SHA1 working on the iPhone:

uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

CC_SHA1(keyData.bytes, keyData.length, digest);

keyData simply contains a constant string of hex code. However the hash hex that I get as a result of this does not match what online SHA1 generators output for the same input hex, but even more wierdly, it does not stay consistent. In other words, I run the hash function once and get one result, twice - another.

Can anyone help, or point me to what I'm doing wrong?

Thank you in advance!

A: 

Update:

I managed to fix the floating problem, I wasn't properly handling the data. The hash is now firmly crooked, although still incorrect. Here is a hex dump of the data: <029a2112 0004231b 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000000>

And here's a hex dump of the SHA1 hash: <244b463b 7a0b2f48 96cfaa01 012823f5 25943ff5>

A: 

Perhaps related to this other question?

David Toso
A: 

No, I was simply mistaken. Instead I used HashCalc by Slavasoft and its output matches that of the iPhone. Forget all the online crap! This issue is closed.