开发者

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 -

  1. http://linglong117.blog.163.com/blog/static/27714547201011142423968/

  2. AES Encryption for an NSString on the iPhone

  3. 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...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜