-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathCryptoTest.java
28 lines (27 loc) · 1.14 KB
/
CryptoTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* Copyright 2016 Jonathan Cross.
* License: WTFPL
*/
import javax.crypto.Cipher;
public class CryptoTest {
public static void main (String[] arg) {
try {
System.out.println("Testing javax.crypto.Cipher key lengths:");
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
if (maxKeyLen > 128) {
System.out.println(" • Congratulations, you have unrestricted key length support!");
} else {
System.out.println(" • Warning: strong crypto not enabled.");
System.out.println(" • For Java 7 and 8, you can install required jars from here:");
System.out.println(" http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip");
System.out.println(" • For Java 9, you simply enable it in your app like so:");
System.out.println(" Security.setProperty(\"crypto.policy\", \"unlimited\");");
}
System.out.println(" • Max key length: " + maxKeyLen);
} catch (Exception e){
System.out.print("ERROR: Could not determine max key length from ");
System.out.println("Cipher.getMaxAllowedKeyLength(\"AES\") : ");
System.out.println(e);
}
}
}