I need to implement 256 bit AES encryption, but all the examples I have found online use a \"KeyGenerator\" to generate a 256 bit key, but I would like to use my own passkey
(Maybe helpful for others with a similar requirement)
I had a similar requirement to use AES-256-CBC
encrypt and decrypt in Java.
To achieve (or specify) the 256-byte encryption/decryption, Java Cryptography Extension (JCE)
policy should set to "Unlimited"
It can be set in the java.security
file under $JAVA_HOME/jre/lib/security
(for JDK) or $JAVA_HOME/lib/security
(for JRE)
crypto.policy=unlimited
Or in the code as
Security.setProperty("crypto.policy", "unlimited");
Java 9 and later versions have this enabled by default.