I installed JCE Unlimited power for JAVA_HOME \ lib \ security
However, I still get 128 for Cipher.getMaxAllowedKeyLength("AES")
.
I am wondering if I installed JCE in the wrong place.
I have Java installed in 2 places.
- C: \ Program Files \ Java \ jre7
- C: \ Development \ Java \ jdk1.6.0_21
Can someone tell me where is the place to install JCE Unlimited? Your help is greatly appreciated.
my code is:
KeyGenerator generator = KeyGenerator.getInstance("AES"); generator.init(256); SecretKey secretKey = generator.generateKey(); byte[] raw= secretKey.getEncoded(); SecretKeySpec sskey= new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); if (mode == Cipher.ENCRYPT_MODE) { Cipher.getMaxAllowedKeyLength("AES")); cipher.init(Cipher.ENCRYPT_MODE, sskey); CipherInputStream cis = new CipherInputStream(is, cipher); doCopy(cis, os); } else if (mode == Cipher.DECRYPT_MODE) { cipher.init(Cipher.DECRYPT_MODE, sskey); CipherOutputStream cos = new CipherOutputStream(os, cipher); doCopy(is, cos); }
source share