iDevGames Forums
generate MD5 strings with Objective-C? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: generate MD5 strings with Objective-C? (/thread-396.html)



generate MD5 strings with Objective-C? - fernandovalente - Jan 26, 2010 10:23 AM

Sorry for posting on an old thread, but how may I generate MD5 strings with Objective-C? I really don't know how to do it. Also a sample code is appreciated. Smile


generate MD5 strings with Objective-C? - backslash - Jan 26, 2010 01:19 PM

There isn't an objective-C class in Cocoa as far as I know, but the Common Crypto API is pretty easy to use, and very fast.
Apple Man Page for Common Crypto
I used that in an app fairly recently and I'm happy with the results.


generate MD5 strings with Objective-C? - cmiller - Jan 26, 2010 01:22 PM

fernandovalente Wrote:Sorry for posting on an old thread, but how may I generate MD5 strings with Objective-C? I really don't know how to do it. Also a sample code is appreciated. Smile

An MD5 hash is a number, so just format print a hex number.

Your MD5 library should already have some function for obtaining a string. Or you could try and format print from a 128-bit unsigned integer.

See also http://www.opensource.apple.com/source/text_cmds/text_cmds-29/md5/md5.c.


generate MD5 strings with Objective-C? - Hog - Jan 27, 2010 09:29 AM

Code:
#include <openssl/md5.h>
...
unsigned char md[16];
MD5(data, n, &md);
...

gives you the md5 hash as binary