iOS MD5加密(32位)

1.引入CJMD5三方库

#import 

3.32位的加密方法

- (NSString *)getMd5_32Bit_String:(NSString *)srcString{
    const char *cStr = [srcString UTF8String];
    unsigned char digest[CC_MD5_DIGEST_LENGTH];
    CC_MD5( cStr, strlen(cStr), digest );
    NSMutableString *result = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
        [result appendFormat:@"%02x", digest[i]];
    
    return result;
}
NSString *md5 = [self getMd5_32Bit_String:_keyTextField.text];

你可能感兴趣的:(iOS MD5加密(32位))