Here you can find the source of generateKey(String key)
private static Key generateKey(String key) throws Exception
//package com.java2s; import java.security.Key; import javax.crypto.spec.SecretKeySpec; public class Main { private static Key generateKey(String key) throws Exception { try {/*w ww. j ava2 s . co m*/ SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "AES"); return keySpec; } catch (Exception e) { e.printStackTrace(); throw e; } } }