Created
June 16, 2012 01:07
-
-
Save bluebanboom/2939453 to your computer and use it in GitHub Desktop.
md5HexDigest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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