Skip to content

Instantly share code, notes, and snippets.

// get MD5 string from a string
+ (NSString*)md5FromString:(NSString*)string {
// // Create pointer to the string as UTF8
const char *ptr = [string UTF8String];
// Create byte array of unsigned chars
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
// Create 16 byte MD5 hash value, store in buffer
CC_MD5(ptr, (CC_LONG)strlen(ptr), md5Buffer);