-1

How to encrypt NSDATA in AES 256 through iso10126padding and CBC mode ,need to do like cipher of android.Please help to do Encryption of NSData with AES256 encryption.

Abhimanyu
  • 11
  • 1
  • 7
  • Show some code also what you have tried and where you are getting problem –  Apr 29 '16 at 10:12

2 Answers2

0

goto this question it will help you : AES Encryption for an NSString on the iPhone

or Goto: https://github.com/RNCryptor/RNCryptor

In Objective-C

Obj-C

//
// Encryption
//
NSString *password = @"Secret password";
RNEncryptor *encryptor = [[RNEncryptor alloc] initWithPassword:password];
NSMutableData *ciphertext = [NSMutableData new];

// ... Each time data comes in, update the encryptor and accumulate some ciphertext ...
[ciphertext appendData:[encryptor updateWithData:data]];

// ... When data is done, finish up ...
[ciphertext appendData:[encryptor finalData]];


//
// Decryption
//
RNDecryptor *decryptor = [[RNDecryptor alloc] initWithPassword:password];
NSMutableData *plaintext = [NSMutableData new];

// ... Each time data comes in, update the decryptor and accumulate some plaintext ...
NSError *error = nil;
NSData *partialPlaintext = [decryptor updateWithData:data error:&error];
if (error != nil) {
    NSLog(@"FAILED DECRYPT: %@", error);
    return;
}
[plaintext appendData:partialPlaintext];

// ... When data is done, finish up ...
NSError *error = nil;
NSData *partialPlaintext = [decryptor finalDataAndReturnError:&error];
if (error != nil) {
    NSLog(@"FAILED DECRYPT: %@", error);
    return;
}

[ciphertext appendData:partialPlaintext];
Community
  • 1
  • 1
0

You can set the attribute to Transformable and use your own Transformer class to apply the encryption/decryption.

This is a guide to Transformable Attributes: enter link description here

Matt39
  • 149
  • 8
  • any useful code for Transformable Attributes, because I need iso10126 padding and CBC mode, i think comoncrpto doest not have the same library. – Abhimanyu Apr 29 '16 at 10:23