title: bad base64 error during decrypting on AES
body: <p>I'm trying to encrypt and decrypt some text using AES algorithm like :</p>
  <pre><code>private static final String ALGORITHM = &quot;AES&quot;;
  private static final String MODE = &quot;AES/CBC/PKCS7Padding&quot;;
  
  
  public String encrypt(String value, String key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
      SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), ALGORITHM);
      Cipher cipher = Cipher.getInstance(MODE);
      cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(key.getBytes()));
      byte[] values = cipher.doFinal(value.getBytes());
      return Base64.encodeToString(values, Base64.URL_SAFE);
  }
  
  public String decrypt(String value, String key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
  
      byte[] values = Base64.decode(value, Base64.DEFAULT);
      SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), ALGORITHM);
      Cipher cipher = Cipher.getInstance(MODE);
      cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(key.getBytes()));
      return new String(cipher.doFinal(values));
  }
  </code></pre>
  <p>The encrypting code works perfectly fine but when I'm trying to decrypt the encrypted text it returns a <strong>bad base64</strong> error.</p>
  <p>What I <strong>tried to do before</strong>:</p>
  <p>I already tried to <strong>change <strong>Base64.<em>DEFAULT</em></strong> to <strong>Base64.<em>URL_SAFE</em></strong></strong> but it gave me the same error.</p>
  <p>Also, I tried to <strong>replace &quot;</strong>/<strong>&quot; and &quot;</strong>+<strong>&quot; with &quot;</strong>_<strong>&quot; and &quot;</strong>-<strong>&quot;</strong> and it doesn't work either.</p>
  <p>Heres the value I'm encrypted and trying to decrypt:</p>
  <p><strong>Ssg2w+dv7es7/wWAeAcoAOSVnYKsoLlefbmS8tYr+jc=</strong></p>
  <p>Thanks for helping...</p>