title: Java crypto API vs. different platforms
body: <p>I have an Android application, which uses <code>javax.crypto</code> to encrypt some text data in files. Encryption implementation is similar to <a href="http://www.tutorials-android.com/learn/How_to_encrypt_and_decrypt_strings.rhtml" rel="nofollow">this</a>. The application works fine with the encrypted data it previously created.</p>
  
  <p>Now, I almost ported my Android application to desktop (JFace/SWT). I'm using the same encryption implementation for the ported application, as it does not depend on any Android-specific API. The ported application works fine with encrypted data it created.</p>
  
  <p>The problem is that desktop application cannot decrypt data, which was saved with Android application. The Android application fails to decrypt data, which was saved with desktop application as well. I double checked bytes streams of plain data and password to encrypt on both platforms. They are the same, so there are no problems with text encoding or so. But encryption routine return different encrypted results on different platforms even input data is byte-to-byte identical.</p>
  
  <p>Does Java crypto API guarantees the same operation on different platforms? Should an encryption provider (AES/128bit in my case) work the same way on Android, Linux and Windows? Is there a way to tune <code>javax.crypto</code> to get interoperability on different platforms?</p>