#import "MD5Untils.h"
#define MD5_LENGTH 16
#import <CommonCrypto/CommonDigest.h>
@implementation MD5Untils
+ (NSString *)MD5WithStr:(NSString *)originStr{
const char *cString = [originStr UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(cString, (CC_LONG)originStr.length, result);
NSMutableString *designStr = [NSMutableString string];
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
[designStr appendFormat:@"%02x", result[i]];
}
return designStr;
}
@end
网友评论