1.NSData和 base64 NSString的转换
- NSString base64编码后的转NSData
NSData *contentData = [[NSData alloc] initWithBase64EncodedString:content options:NSDataBase64DecodingIgnoreUnknownCharacters];
2.NSData转base64编码的字符串
NSData *encrptedData
[encrptedData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
2. NSData和NSString转换
1.NSString 转NSData
NSData *contentData = [content dataUsingEncoding:NSUTF8StringEncoding];
2.NSData 转NSString
NSString *con = [[NSString alloc] initWithData:encrptedData encoding:NSUTF8StringEncoding];
3.NSData和bytes的转换
1.NSData 转bytes
NSData *contentData
void const *initVectorBytes = contentData.bytes //void const *表示可以指向任何类型的指针
2.bytes转NSData
[NSData dataWithBytes:operationBytes length:actualOutSize]
4.NSString和bytes的转换
1.NSString转bytes
void const *initVectorBytes = [kInitVector UTF8String];
2.bytes转NSString
NSString *data = [NSString stringWithCString:contentBytes encoding:NSUTF8StringEncoding];
网友评论