MD5加密

必须头文件

#import <CommonCrypto/CommonDigest.h>

// MD5 32位加密

-(NSString *)md5_32:(NSString *)str bool_isUpper:(BOOL)bool_isUpper

{

    const char *cStr = [str UTF8String];

    unsigned char result[32];

    CC_MD5(cStr, (CC_LONG)strlen(cStr), result);

    NSMutableString *hash = [NSMutableString string];

    for (int i = 0; i < 16; i++)

    {

        [hash appendFormat:@"%02X", result[i]];

    }

    if (bool_isUpper) {

        return [hash uppercaseString];

    }else{

        return [hash lowercaseString];

    }

    

}

posted @ 2016-08-10 19:54  前路弯弯  阅读(110)  评论(0)    收藏  举报