//转换图片的方法Base64
- (NSString *)UIImageToBase64Str:(UIImage *)image
{
NSData *data = UIImagePNGRepresentation(image);
NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
return encodedImageStr;
}
//把字符串转成Base64编码
- (NSString *)base64EncodeString:(NSString *)string
{
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
return [data base64EncodedStringWithOptions:0];
}
//字符串解码
- (NSString *)stringEncodeBase64:(NSString *)base64
{
NSData *nsdataFromBase64String = [[NSData alloc]initWithBase64EncodedString:base64 options:0];
NSString *base64Decoded = [[NSString alloc]initWithData:nsdataFromBase64String encoding:NSUTF8StringEncoding];
return base64Decoded;
}