title: AES 128 bit & AES 256 bit encryption decryption
body: <p>I am doing AES 128 bit encyption and decryption using following java code which works fine. For same key and data it gives me same output each time.</p>
  
  <p>link1: <a href="http://aesencryption.net/#Java-aes-encryption-example" rel="nofollow noreferrer">http://aesencryption.net/#Java-aes-encryption-example</a> </p>
  
  <pre><code>(final String strPssword = "dAtAbAsE98765432";)
  </code></pre>
  
  <p>For AES 256 bit encryption and decryption I found another java code.
  It gives me different output each time.</p>
  
  <p>link2: <a href="https://stackoverflow.com/questions/28622438/aes-256-password-based-encryption-decryption-in-java">AES-256 Password Based Encryption/Decryption in Java</a></p>
  
  <p>My question is that, 
  whether i need to wirte different code for AES 128 bit and AES 256 bit?
  Or are they same? only key size is different?</p>
  
  <p>For 256 bit encryption only i need to change in first java code link</p>
  
  <pre><code>public boolean setKey(String sKey){
      arbtKey = Arrays.copyOf(arbtKey, 32); // use only first 256 bits
  }
  
  public static void main(String[] aryCmdArgs)
  {
      final String sKey = "dAtAbAsE98765432dAtAbAsE98765432"; //256 bits
  }
  </code></pre>
  
  <p>or i need to use a code given in link2?</p>