MD5加密

作者: BeSt2wazi | 来源:发表于2017-07-13 17:16 被阅读0次
    - (NSString *) md5WithString
    {
        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 [NSString stringWithString:outputString];
    }
    

    相关文章

      网友评论

          本文标题:MD5加密

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