JNCryptor on Android to RNCryptor-php

503 views Asked by At

I have a file in my android app that I want to upload to the server. I am using JNCryptor for AES 256 encryption. I have the RNCryptor-php library on my server and I am trying to decrypt the file, but it is not getting decrypted correctly. Here is my code:

Android:

String password = '12345678901234561234567890123456';
File file = new File(filename);
byte[] originalBytes = FileUtils.readFileToByteArray(file);
byte[] encryptedBytes = new AES256JNCryptor().encryptData(originalBytes, password.toCharArray());
FileUtils.writeByteArrayToFile(file, encryptedBytes);

PHP

$password = '12345678901234561234567890123456';
$cryptor = new \RNCryptor\Decryptor();
$decryptedData = $cryptor->decrypt($string, $password);

$handle = fopen($decrypted_filename, "w");
fwrite($handle, $decryptedData);
fclose($handle);

Any help would be much appreciated! Thanks!

1

There are 1 answers

0
user284635 On

Does this help? There is some code and logic discussed that seems very relevant.

https://github.com/RNCryptor/JNCryptor/issues/21