
版权声明:本文为博主原创文章,未经博主允许不得转载。
iOS自带MD5加密
#import <CommonCrypto/CommonDigest.h>
- (NSString *)MD5:(NSString *)mdStr
{
const char *original_str = [mdStr 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 < CC_MD5_DIGEST_LENGTH; i++)
[hash appendFormat:@"%02X", result[i]];
return [hash lowercaseString];
}
转自:http://blog.youkuaiyun.com/liu_esther/article/details/51434845