title: Error : javax.crypto.BadPaddingException: pad block corrupted while Decryption
body: <p>I have done Encryption with ,</p>
  
  <pre><code>public static String encrypt(String plainText) {
      try {
          byte[] keyData = secret_key.getBytes();
          SecretKeySpec secretKey = new SecretKeySpec(keyData, "AES/ECB/PKCS7Padding");
          Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
          cipher.init(Cipher.ENCRYPT_MODE, secretKey);
  
          byte[] cipherText = cipher.doFinal(plainText.getBytes("UTF-8"));
          String encryptedString = Base64.encodeToString(cipherText, Base64.NO_WRAP);
  
          return encryptedString;
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>it's working well.</p>
  
  <p>but part of <code>Decryption</code> gives Error like,</p>
  
  <pre><code>W/System.err: javax.crypto.BadPaddingException: pad block corrupted
  W/System.err:     at com.android.org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(JCEBlockCipher.java:701)
  W/System.err:     at javax.crypto.Cipher.doFinal(Cipher.java:1111)
  </code></pre>
  
  <p><code>decrypt</code> Code like,</p>
  
  <pre><code>public static String decrypt(String encryptedText) {
      try {
          byte[] keyData = secret_key.getBytes();
          SecretKeySpec secretKey = new SecretKeySpec(keyData, "AES/ECB/PKCS7Padding");
          Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
          cipher.init(Cipher.DECRYPT_MODE, secretKey);
  
          byte[] cipherText = Base64.decode(encryptedText,Base64.NO_WRAP);
          String decryptedString = new String(cipher.doFinal(cipherText),"UTF-8");
  
          return decryptedString;
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>here what is the problem? How can i solve this Issue?</p>