1

Hellp All,

I have used RNCryptor/JNCryptor for iOS and android following is the code for encrypt in Android and Decrypt in iOS.

Encrypt code in Android

public static String EncryptMessage(String message)
{
JNCryptor cryptor = new AES256JNCryptor();
byte[] plaintext = message.getBytes();
byte[] ciphertext = null;

try {
ciphertext = cryptor.encryptData(plaintext,Constants.ENCRYPTION_KEY.toCharArray());
} catch (CryptorException e) {
// Something went wrong
e.printStackTrace();
}

return  Base64.encodeBytes(ciphertext);
}

Decrypt code in iOS

 NSData *fromAData =     [@"AwEche05IIj/OYEN5brgF/p6jyfKfARJliUQwEwa2lko40+ScPMumlDSIZWB2O6XRZjIucXVbggieWaHb2x6sJkYYt7tn3k17V5Jd5PAnkIoFA==" base64DecodedData];

NSData *fromADecryptedData = [RNDecryptor decryptData:fromAData withSettings:kRNCryptorAES256Settings password:@"password" error:&decryptionError];
NSLog(@"decryptionError %@", decryptionError);
NSLog(@"Result = %@", fromPHPDecryptedData);
NSLog(@"Result = %@", [[NSString alloc] initWithData:fromADecryptedData encoding:NSUTF8StringEncoding]);

I have also tried simple decrypt with password

 NSData *fromADecryptedData = [RNDecryptor decryptData:fromAData withPassword:@"password" error:&decryptionError];

Getting the error of unknown header, error code=2

I am using same sting "password" as password at both the side.

If anyone has any idea please let me know if i am missing anything.

Satish
  • 1,012
  • 2
  • 15
  • 32

1 Answers1

2

It worked once I updated my RNcryptor library in my iOS...

My iOS RNcryptor library version is v2.2

Android Version 1.2.0

Satish
  • 1,012
  • 2
  • 15
  • 32
  • We have used the RNcryptor android module. Did't support the latest android studio 3.6.3 version and didn't upgrade the lastest os. Please help me. https://stackoverflow.com/questions/62407092/android-studio-3-6-3-not-supporting-for-rncryptor-module – Manikandan K Jun 16 '20 at 11:48