how convert NSMutableData to NSString?
how convert NSMutableData to NSString?
NSString *strData = @"Bonjour tout le monde, je voudrais vous présenter la Société Futur";
NSLog(@"before encr开发者_Python百科yption : %@",strData);
NSMutableData *objNSData = [NSMutableData dataWithData:[strData dataUsingEncoding:NSUTF16StringEncoding]];
objNSData = [objNSData EncryptAES:@"samplekey"];
///NSLog(@"encryption : %@", objNSData);
NSString * strData1= [[NSString alloc] initWithData:objNSData encoding:NSUTF16StringEncoding];
NSLog(@"encryption : %@", strData1);
Try with below
NSString * strData1= [[NSString alloc] initWithData:myMutableData encoding:NSUTF8StringEncoding];
Following links may help you -
http://linglong117.blog.163.com/blog/static/27714547201011142423968/
AES Encryption for an NSString on the iPhone
https://gist.github.com/838614
These can help you to go through with the encryption methods and their correct implementation using category.
Please refer this Link
For different encoding , there is other methods also..
Converting NSString to NSData
NSString* str= @"teststring";
NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding];
Update
For Encryption and decryption, See This Link and download source code...
精彩评论