title: 'BadPaddingException: pad block corrupted' while decrypting using AES/ECB
body: <p>In Android/java app,</p>
  
  <pre><code>byte[] data = ":Êº$jhk¨ë‹òºÃ"; // fetched from php server..
  Cipher cipher = Cipher.getInstance("AES");
  cipher.init(Cipher.DECRYPT_MODE, mKeyspec);
  return new String(cipher.doFinal(data));
  </code></pre>
  
  <p>The above code always throws <code>BadPaddingException: pad block corrupted</code> for following 16 byte encypted data   </p>
  
  <blockquote>
    <p>data = ":Êº$jhk¨ë‹òºÃ" (the data is 16 chars)</p>
  </blockquote>
  
  <p>The key is 16 bytes long.</p>
  
  <p>Why does it throw this exception when the data is already the size of a block.? and no padding is needed.</p>
  
  <p>Note: The encrypted data is fetched from a php server.  </p>
  
  <h2>Edit:</h2>
  
  <p>After changing to<br>
  <code>Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");</code><br>
  from<br>
  <code>Cipher cipher = Cipher.getInstance("AES");</code></p>
  
  <p>the decrypt method succeeds, but gives this output
  <img src="https://i.stack.imgur.com/cBUOU.png" alt="enter image description here"></p>