NSMutableData convert to NSString
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.
精彩评论