I have been, already for some time, trying to encrypt some XML files in android with AES, send them using FTP to a server, and then unencrypt them, preferably using terminal invoked java.It was not difficult to setup the encryption, as there are lots of examples out there, but every one of them, when finally got it working, it worked only on about 75% of the files. The rest get unencrypted up to some point, then produces garbage. I thought it would be maybe because the difference between android java and my linux java libraries, so I tried to unencrypt the files inside an android emulator. No use.At some point, I read about BouncyCastle libraries being outdated in android java, and decided to download spongycastle jars and use them, to no avail.The thing is, the files which fail do it always at the same point. I thought it maybe was because of the UTF-8 encoding, so I tried to encode them to Base64 first. They just fail at another point.I will not cite every library I tried, since they were many, many of them. Also, all of them fail, so the problem is most probably not there.The last one I am trying to make it work are the encodeDecodeAES.java with the Base64Coder from here:EncodeDecodeAES.javaThe error I'm getting now is "javax.crypto.IllegalBlockSizeException: last block incomplete in decryption"What I want is: Encode a file in an android app. Send it with FTP. Decode it in the server using a terminal-invoked java class.What's making me crazy is that most of the files work just fine... The ones that fail aren't bigger or smaller than the rest, sometimes are big ones, sometimes small ones.Oh, I also tried removing every \r\n before encrypting the files. All the same.I thought maybe the key being in string format could be a problem, but I tried in other libraries with byte format and it didn't work. The library I'm using now only receives string format, so that's what I'm using.The code I'm currently using now is:\[code\]String fileNotEncrypted=Environment.getExternalStorageDirectory() + "unencrypted.xml";RandomAccessFile fileNotEncryptedRa = new RandomAccessFile(fileNotEncrypted, "r");byte[] textNotEncryptedByte = new byte[(int)fileNotEncryptedRa.length()];fileNotEncryptedRa.read(textNotEncryptedByte);Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);byte[] textEncryptedByte = EncodeDecodeAES.encryptBytes("1234567890123456", textNotEncryptedByte); String fileEncrypted=Environment.getExternalStorageDirectory() + "encrypted.xml";FileOutputStream fos = new FileOutputStream(fileEncrypted);fos.write(textEncryptedByte);fos.close();\[/code\]