djboss
djboss

Reputation: 59

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 encryption : %@",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);

Upvotes: 2

Views: 4445

Answers (3)

Mehul Mistri
Mehul Mistri

Reputation: 15147

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

Upvotes: 0

Kapil Mandlik
Kapil Mandlik

Reputation: 174

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.

Upvotes: 0

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31722

Try with below

NSString * strData1= [[NSString alloc] initWithData:myMutableData encoding:NSUTF8StringEncoding];

Upvotes: 2

Related Questions