Java tutorial
//package com.java2s; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; public class Main { public static byte[] encryptAES(SecretKey sKey, byte[] message) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { Cipher c = Cipher.getInstance("AES"); c.init(Cipher.ENCRYPT_MODE, sKey); return c.doFinal(message); } }