Here you can find the source of getSecretKey(String key)
private static SecretKeySpec getSecretKey(String key)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.crypto.spec.SecretKeySpec; public class Main { private static final String UTF_8 = "UTF-8"; private static SecretKeySpec getSecretKey(String key) { MessageDigest digest;/*from w ww . j a va2s . co m*/ try { digest = MessageDigest.getInstance("md5"); SecretKeySpec keySpec = new SecretKeySpec(digest.digest(key .getBytes(UTF_8)), "AES"); return keySpec; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } }