Skip to content

Instantly share code, notes, and snippets.

@nogweii
Created October 1, 2013 23:39
Show Gist options
  • Save nogweii/6786915 to your computer and use it in GitHub Desktop.
Save nogweii/6786915 to your computer and use it in GitHub Desktop.
A quick test to see if you have the JCE Unlimited Strength Jurisdiction Policy files installed. If you don't, in Java 6 you'll see 128. If you do, you'll see 2147483647. Thanks to http://stackoverflow.com/questions/11538746/check-for-jce-unlimited-strength-jurisdiction-policy-files
#!/bin/bash
javac Test.java
java Test
import javax.crypto.Cipher;
class Test {
public static void main(String[] args) {
try {
System.out.println("Hello World!");
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
System.out.println(maxKeyLen);
} catch (Exception e){
System.out.println("Sad world :(");
}
}
}
@TiloGit
Copy link

TiloGit commented Nov 7, 2017

thanks for the info. Here mod one liner for WAS (IBM) on Win
C:\IBM\WebSphere\AppServer\java\8.0\bin\jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('AES'))"
C:\IBM\WebSphere\AppServer\java_1.7.1_64\bin\jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('AES'))"

If you want true/false
jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('AES') >= 256)"
jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('RC5') >= 256)"

@kfowlks
Copy link

kfowlks commented Dec 6, 2017

Excellent work!

@daudich
Copy link

daudich commented Jun 26, 2018

Thanks for this and the one liners!

@jacky1104
Copy link

Thanks dude.

@razorsedge
Copy link

unzip -c ${JAVA_HOME}/jre/lib/security/local_policy.jar default_local.policy | grep -q javax.crypto.CryptoAllPermission && echo "unlimited JCE" || echo "vanilla JCE"

@scotlynhatt
Copy link

In Eclipse:
image

@mnlservices
Copy link

Great help, thanks for the post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment