Skip to content

Instantly share code, notes, and snippets.

@johnclayton
Created May 24, 2013 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnclayton/5646870 to your computer and use it in GitHub Desktop.
Save johnclayton/5646870 to your computer and use it in GitHub Desktop.
- (NSString *) MD5Hash {
const char *cStr = [self UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5( cStr, (CC_LONG)strlen(cStr), result );
NSMutableString *hash = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for (int i = 0; i < 16; i++) {
[hash appendFormat: @"%02x", result[i]];
}
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment