Here you can find the source of secretKey(final String key)
public static SecretKey secretKey(final String key)
//package com.java2s; //License from project: Apache License import javax.crypto.SecretKey; import javax.security.auth.DestroyFailedException; public class Main { private static final String ALGO = "AES"; public static SecretKey secretKey(final String key) { return new SecretKey() { private static final long serialVersionUID = -829558999158937420L; public String getAlgorithm() { return ALGO; }//from www . j av a 2s.co m public byte[] getEncoded() { return key.getBytes(); } public String getFormat() { return "RAW"; } @Override public void destroy() throws DestroyFailedException { // TODO Auto-generated method stub } @Override public boolean isDestroyed() { // TODO Auto-generated method stub return false; } }; } }