Create a gist now

Instantly share code, notes, and snippets.

Detect the allowed size of AES keys on the JVM. If the size is <= 256, it is limited. To fix it JCE unlimted stregth files are needed.
import javax.crypto.Cipher;
public class KeyLengthDetector {
public static void main(String[] args) {
int allowedKeyLength = 0;
try {
allowedKeyLength = Cipher.getMaxAllowedKeyLength("AES");
} catch (NoSuchAlgorithmException e) {
System.out.println("The allowed key length for AES is: " + allowedKeyLength);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment