Here you can find the source of createKey(String password)
private static SecretKeySpec createKey(String password)
//package com.java2s; import java.io.UnsupportedEncodingException; import javax.crypto.spec.SecretKeySpec; public class Main { private static SecretKeySpec createKey(String password) { byte[] data = null; if (password == null) { password = ""; }//w w w . j a va 2 s . c o m StringBuffer sb = new StringBuffer(32); sb.append(password); while (sb.length() < 32) { sb.append("0"); } if (sb.length() > 32) { sb.setLength(32); } try { data = sb.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return new SecretKeySpec(data, "AES"); } }