I added the following to my "NSString+MyGoonk" category:
#include <openssl/md5.h>
- (NSString *)md5
{
NSData *data = [self dataUsingEncoding: NSUTF8StringEncoding];
unsigned char *digest = MD5([data bytes], [data length], NULL);
return [NSString stringWithUTF8String: (char *)digest];
}
Two things:
this assumes your string is UTF8. I'm sure there's a way to make it more generic, but I almost never use anything else.
you have to link -lcrypto into your project.