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!
Does this help? There is some code and logic discussed that seems very relevant.
https://github.com/RNCryptor/JNCryptor/issues/21