title: what is wrong in java AES decrypt function?
body: <p>i modified the code available on 
  <a href="http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html" rel="nofollow noreferrer">http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html</a></p>
  
  <p>and made encrypt and decrypt methods in program. but i am getting BadpaddingException..
  also the function is returning null..
  why it is happing?? whats going wrong? please help me..</p>
  
  <p>these are variables i am using:</p>
  
  <pre><code>
  kgen = KeyGenerator.getInstance("AES");
              kgen.init(128);
              raw = new byte[]{(byte)0x00,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55,(byte)0x66,(byte)0x77,(byte)0x88,(byte)0x99,(byte)0xaa,(byte)0xbb,(byte)0xcc,(byte)0xdd,(byte)0xee,(byte)0xff};
              skeySpec = new SecretKeySpec(raw, "AES");
              cipher = Cipher.getInstance("AES");
  
              plainText=null;
              cipherText=null;
  
  </code></pre>
  
  <p>following is decrypt function..</p>
  
  <pre><code>
  public String decrypt(String cipherText)
      {
          try
          {
              cipher.init(Cipher.DECRYPT_MODE, skeySpec);
              byte[] original = cipher.doFinal(cipherText.getBytes());
              plainText = new String(original);
          }
  
  
          catch(BadPaddingException e)
          {
  
          }
  
          return plainText;
      }
  </code></pre>