开发者

NSMutableData convert to NSString

开发者 https://www.devze.com 2023-03-16 11:09 出处:网络
Why data not similar with objNSData? NSString *strData = @\"Bonjour tout le monde, je voudrais vous présenter la Société fdfdfdfFutur\";

Why data not similar with objNSData?

NSString *strData = @"Bonjour tout le monde, je voudrais vous présenter la Société fdfdfdf  Futur";
NSMutableData *objNSData = [NSMutableData dataWithData:[strData dataUsingEncoding:NSUTF8StringEncoding]];

objNSData = [objNSData EncryptAES:@"samplekey"];

 NSLog(@"objNSData%@", objNSData);

NSString *str=[[NSString alloc] initWithData: objNSData encoding:NSUTF8StringEncoding];

NSLog(@"str%@",str);

NSMutableData *data = [[NSMutableData alloc] initWithData:[ str dataU开发者_StackOverflow中文版singEncoding:NSUTF8StringEncoding]];
 NSLog(@"data%@",data);


You seem to be storing the NSData representation of the string, then encrypting it and hoping that converting it back will give you the same thing you started out with.

While I'm not entirely sure why you're trying to encrypt your NSData instance, if you want to convert it back into an NSString then you most definitely want to decrypt it on the way back.

0

精彩评论

暂无评论...
验证码 换一张
取 消