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 <CommonCrypto/CommonDigest.h>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章