Here you can find the source of encrypt(byte[] raw, byte[] clear)
private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception
//package com.java2s; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; public class Main { private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception { SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); byte[] encrypted = cipher.doFinal(clear); return encrypted; }//from ww w . j av a 2 s .co m }