title: AES128 Decryption :javax.crypto.badpaddingexception pad block corrupted
body: <p>I try to decrypt an encrypted data that I receive from a web service.</p>
  
  <p>The encryption is done using <code>AES 128</code>.</p>
  
  <p>I use the following code to decrypt the data:</p>
  
  <pre><code>public static String decrypt(String strToDecrypt)
  {       
      try
      {
          Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); //AES/CBC/PKCS7Padding
          SecretKeySpec secretKey = new SecretKeySpec(AppConstants.AESEncryptionKey.getBytes("UTF8"), "AES");
          int blockSize = cipher.getBlockSize();
          cipher.init(Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(new byte[blockSize])); //new IvParameterSpec(new byte[16])
          byte decBytes[] = cipher.doFinal(Base64.decode(strToDecrypt, 0));
          // byte decBytes[] = cipher.doFinal(Base64.decodeBase64(strToDecrypt));
          String decStr = new String(decBytes);
          System.out.println("After decryption :" + decStr);
          return decStr;
      }
      catch (Exception e)
      {
          System.out.println("Exception in decryption : " + e.getMessage());
      }
      return null;
  }
  </code></pre>
  
  <p>At </p>
  
  <blockquote>
    <p>cipher.doFinal()</p>
  </blockquote>
  
  <p>I got the following Exception:</p>
  
  <blockquote>
    <p>javax.crypto.badpaddingexception pad block corrupted</p>
  </blockquote>
  
  <p>I went through my post but ended up with no solution. I am badly stuck over here.</p>