IOS加密

IOS加密先在挺多的都是MD5(32位)加密,base64加密,AES(256)加密

1,md5加密,这个实现起来比较方便直接写个方法就可以了但是要注意的是需要引入内部的一个头文件#import CommonCrypto/CommonDigest.h 
传入需要加密的字符串,生成加密后的字符串

- (NSString *)md5:(NSString *)str
{
const char *cStr = [str UTF8String];
unsigned char result[16];
CC_MD5(cStr, strlen(cStr), result); // This is the md5 call
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]
];
}

如果有需要可以自行将其写成一个字符串的类方法,方便调用

2、AES加密

猜你喜欢

转载自blog.csdn.net/ZhaiAlan/article/details/53031574