AES custom key instead of 16, 24 or 32 bytes
<p>I am having problems with <code>keys AES</code> in Java</p>

<p>This is my code:</p>

<pre><code>public Core(String key) {
    try {
        this.SecretKey = key;
        this.ivspec = new IvParameterSpec(this.iv.getBytes());
        this.keyspec = new SecretKeySpec(SecretKey.getBytes("UTF-8"), "AES");
        try {
            this.cipher = Cipher.getInstance("AES/CBC/NoPadding");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
}
</code></pre>

<p>Whenever I pass the String "key" that contains for example <code>Pizza</code>, it just generates errors. When I pass for example a String that contains precisely 16 bytes, it works. I would like to use AES, but I would not like it to only be limited to 16, 24 or 32 bytes. How can I fix this? </p>