NSString类别方法
//md5加密
- (NSString *)md5 {
if(self == nil || [self length] == 0) return nil;
const char *value = [self UTF8String];
unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH];
CC_MD5(value, strlen(value), outputBuffer);
NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++)
{
[outputString appendFormat:@"%02x", outputBuffer[count]];
}
return outputString;
}
需要 #import <CommonCrypto/CommonDigest.h>
1万+

被折叠的 条评论
为什么被折叠?



