-
Base64解码和编码
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
NSString *string = [self base64EncodeString:@"A"];
NSString *base64String = [self base64decodeString:@"QQ=="];
NSLog(@"string = %@",string);
NSLog(@"base64String = %@",base64String);
}
//对一个字符串进行base64编码
-(NSString *)base64EncodeString:(NSString *)string
{
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
return [data base64EncodedStringWithOptions:0];
}
//对一个字符串进行base解码
-(NSString *)base64decodeString:(NSString *)string
{
NSData *data = [[NSData alloc]initWithBase64EncodedString:string options:0];
return [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
}
常用解密分类https://github.com/liuxingchen930831/iOS-Decrypt-the-category