美文网首页
字符串MD5加密

字符串MD5加密

作者: 张家杰仔 | 来源:发表于2017-04-11 13:40 被阅读19次
- (NSString *) md5:(NSString *) input {
    const char *cStr = [input UTF8String];
    unsigned char digest[CC_MD5_DIGEST_LENGTH];
    CC_MD5( cStr, strlen(cStr), digest ); // This is the md5 call
    
    NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    
    for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
        [output appendFormat:@"%02x", digest[i]];
    
    return  output;
}

相关文章

网友评论

      本文标题:字符串MD5加密

      本文链接:https://www.haomeiwen.com/subject/gkmtattx.html