Java tutorial
//package com.java2s; //License from project: Apache License import java.security.Key; import javax.crypto.spec.SecretKeySpec; public class Main { public static Key byteArrayKeyToSecurityKeyUsingLength(byte[] key) throws Exception { return new SecretKeySpec(key, 0, key.length, "AES"); } }