首页 > 代码库 > iOS MD5加密算法

iOS MD5加密算法

 1 //MD5加密
 2 + (NSString *)md5HexDigest:(NSString*)password
 3 {
 4    const char *original_str = [password UTF8String];
 5    unsigned char result[CC_MD5_DIGEST_LENGTH];
 6    CC_MD5(original_str, strlen(original_str), result);
 7    NSMutableString *hash = [NSMutableString string];
 8    for (int i = 0; i < 16; i++) {
 9        [hash appendFormat:@"%02X", result[i]];
10    }
11     NSString *mdfiveString = [hash lowercaseString];
12 
13     return mdfiveString;
14 }

 

iOS MD5加密算法