标签:
#import <CommonCrypto/CommonDigest.h>
@interface NSString (md5)
-(NSString *) md5HexDigest;
@end
#import "NSString+MD5HexDigest.h"
@implementation NSString (md5)
-(NSString *) md5HexDigest
{
const char *original_str = [self UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(original_str, strlen(original_str), result);
NSMutableString *hash = [NSMutableString string];
for (int i = 0; i < 16; i++)
[hash appendFormat:@"%02X", result[i]];
return [hash lowercaseString];
}
@end
标签:
原文地址:http://www.cnblogs.com/linxiu-0925/p/5070944.html