public class AesCBCEncDEc {

public String plainText;
public String encrypt_key = "MySixteenCharKey";
static byte iv[] = new byte[16];


public static byte[] encryptText(String plainText, byte[] enc_key) throws Exception {
    Cipher aesCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
     SecretKeySpec key = new SecretKeySpec(enc_key, "AES");
     aesCipher.init(Cipher.ENCRYPT_MODE, key,new IvParameterSpec(iv));
    byte[] byteCipherText = aesCipher.doFinal(plainText.getBytes());
    return byteCipherText;
} 


  public static String decrypt(byte[] cipherText, byte[] enk_key) throws Exception{
        //Cipher aesCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        Cipher aesCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        SecretKeySpec key = new SecretKeySpec(enk_key, "AES");
        aesCipher.init(Cipher.DECRYPT_MODE, key,new IvParameterSpec(iv));
        return new String(aesCipher.doFinal(cipherText));
    }

  public static void main(String[] args) throws Exception {
    String palinText = "Sunil YAdav";
    String secretKey = "MySixteenKey1234";
    byte b[] = AesCBCEncDEc.encryptText(palinText, secretKey.getBytes());
    System.out.println(""+AesCBCEncDEc.decrypt(b, secretKey.getBytes()));
}

}