[ios]md5加密

//
//  MD5Unit.m
//  EntranceGuard
//
//  Created by liu poolo on 13-4-26.
//  Copyright (c) 2013年 liu poolo. All rights reserved.
//

#import "MD5Unit.h"
#import "CommonCrypto/CommonDigest.h"
@implementation MD5Unit
+(NSString *) md5: (NSString *) inPutText
{
    const char *cStr = [inPutText UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    CC_MD5(cStr, strlen(cStr), result);
    //%X 取16进制
    //%02X 取16进制 保留两位整数
    return [[NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
             result[0], result[1], result[2], result[3],
             result[4], result[5], result[6], result[7],
             result[8], result[9], result[10], result[11],
             result[12], result[13], result[14], result[15]
             ] lowercaseString];
}
@end

 

猜你喜欢

转载自poolo.iteye.com/blog/1855270