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 }

 

posted @ 2017-02-20 09:08  福泽小院  阅读(137)  评论(0编辑  收藏  举报