13 replies
Sign in or join Beachball Help to reply.
- 0
EagerEyes ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
No, that's not what it means. It means that the iPhone has a convenient uniqueID, whereas they use a a hash of the MAC when running on a Mac. I just dropped some of that code from WiTap into my program and compiles and works fine on the iPhone.
- 0
henson2k ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
EagerEyes wrote:
There's a function CC_MD5, which is used in the WiTap example.Unfortunately WiTap's code contains condition:
#if TARGET
OSIPHONE
uniqueID = [[UIDevice currentDevice] uniqueIdentifier];
.....................
#else
.....................
if((buffer = [uniqueID UTF8String])) {
bzero(md5, CC
MD5_DIGESTLENGTH);
CC_MD5(buffer, strlen(buffer), md5);
............................................
#endifBasically that means CC_MD5 call can't be used with iPhone OS
- 0
joostjoost ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
One of my iPhone apps uses the <CommonCrypto/CommonDigest.h> framework for calculating hashes. There is plenty of documentation in the XCode doc sets on the subject. Do a full text search in All Doc Sets for 'CommonDigest'. You will find the CC_MD5 man pages. (For new applications it is preferred to use SHA-256.)
In the iPhone Simulator it all works fine. I can not test it on the iPhone itself
btw. You can put the hash bytes in a NSData object using the dataWithBytes message.
- 0
Sbrocket52 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
The CommonCrypto framework is not on the iPhone. Unfortunately, the iPhone Simulator compiles against Mac OS X frameworks so it'll work on the Simulator...but you won't get it to compile for the device.
- 0
johne-dm ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
it seems to compile for the device for me in beta 6.
are you using the latest beta?
i should say that it compiles for me... i have not tried it on the device cause the code i'm using used NSXMLDocument, which does not compile on the iphone, yet.
- 0
Sbrocket52 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Compiles or runs?
I dunno what headers you're compiling for if it does compile, though, because +there are no CommonCrypto headers for the iPhone+. You can check for yourself.
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Lib rary/PrivateFrameworks/
Message was edited by: Sbrocket52
- 0
johne-dm ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
i'm wondering if i'm including them from the wrong place, but they are all right here:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/includ e/CommonCrypto/
i include it and use it like this:
#import <CommonCrypto/CommonDigest.h>
....
unsigned char digest[16];
char finaldigest[32];
int i;
CC_MD5([self bytes],[self length],digest); - 0
EagerEyes ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I just tried this and it works fine on the device. The header is here:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/includ e/CommonCrypto/CommonDigest.h
I guess that is because it's not part of a framework but of the C library? No idea. In any case, it pays to try things out ...
EDIT: looks like you found it while I was compiling ...
- 0
Vroomtrap ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
<pre class="jive-pre">
// Import library
#import <CommonCrypto/CommonDigest.h>
...
// Function definition
NSString * md5( NSString *str )
{
const char *cStr = [str UTF8String];
unsigned char result[CC
MD5_DIGESTLENGTH];
CC_MD5( cStr, strlen(cStr), result );
return [NSString
stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
result[0], result[1],
result[2], result[3],
result[4], result[5],
result[6], result[7],
result[8], result[9],
result[10], result[11],
result[12], result[13],
result[14], result[15]
];
}
...
// Implementation
NSString *digest = md5(@"test");
NSLog(@"MD5 TEST %@", digest);
</pre>The answer you should get is:
098F6BCD4621D373CADE4E832627B4F6
You can check your results on this page
http://www.adamek.biz/md5-generator.php - 0
itripn ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I posted code using openssl over here to do this:
http://discussions.apple.com/message.jspa?messageID=7025577#7025840
rjf&
- 0
EagerEyes ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
There's a function CC_MD5, which is used in the WiTap example.
- 0
henson2k ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Thank you for explanation!
It works now!
- 0
Sbrocket52 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Heh, nevermind - my programming fu must be off today.
Why was I looking for a C library in the frameworks folder...
sigh