iOS SDK自带md5加密 (16位)


+ (NSString *) setmd5:(NSString *) input{

    

    //MD5加密

    const char *cStr = [input UTF8String];

    unsigned char digest[16];

    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]];

    NSLog(@"md5===%@",output);

    return  output;

}


注:需要#import

你可能感兴趣的:(iOS总结)