Skip to content

Instantly share code, notes, and snippets.

@bluebanboom
Created June 16, 2012 01:07
Show Gist options
  • Save bluebanboom/2939453 to your computer and use it in GitHub Desktop.
Save bluebanboom/2939453 to your computer and use it in GitHub Desktop.
md5HexDigest
#import <CommonCrypto/CommonDigest.h>
+ (NSString*)md5HexDigest:(NSString*)input
{
const char* str = [input UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(str, strlen(str), result);
NSMutableString *ret = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH*2];
for(int i = 0; i<CC_MD5_DIGEST_LENGTH; i++) {
[ret appendFormat:@"%02x",result[i]];
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment