title: Decrypting "SunJCE" AES encrypted data on Android
body: <p>We need to write some Android code to decrypt some data sent from our server.  Our server team gave us some sample decryption code which uses the "SunJCE" provider, which unfortunately doesn't exist on Android.    </p>
  
  <pre><code>Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding", "SunJCE");
  </code></pre>
  
  <p>Does anybody know the cleanest way to implement this on Android?  If we try this on Android    </p>
  
  <pre><code>Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
  </code></pre>
  
  <p>then it looks like some unwanted garbage appears at the end of the decrypted text, e.g:</p>
  
  <pre><code>ComparisonFailure: expected:&lt;...lAAAAABJRU5ErkJggg==[]&gt; but was:&lt;...lAAAAABJRU5ErkJggg==[��������]&gt;    
  </code></pre>
  
  <p>We tried lots of combinations of different transformations in the Android Cipher class (e.g. "AES/CBC/PKCS5Padding"), but kept hitting things like BadPaddingExceptions.</p>
  
  <p>We were also able to decrypt this data using a Java-only module, which didn't appear to show the same garbage characters.  Is there a way to do this using just Android classes?  </p>