mervick / aes-everywhere

Aes Everywhere - Cross Language AES 256 Encryption Library (Bash, Powershell, C#, Dart, GoLang, Java, JavaScript, Lua, PHP, Python, Ruby, Swift)
Other
478 stars 167 forks source link

java.security.InvalidKeyException: Illegal key size #5

Closed afterbit01 closed 5 years ago

afterbit01 commented 5 years ago

Hello, i have tried

String encrypted = Aes256.encrypt("TEXT", "PASSWORD"); System.out.println(encrypted);

but i get 👍 java.security.InvalidKeyException: Illegal key size at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039) at javax.crypto.Cipher.implInit(Cipher.java:805) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1396) at javax.crypto.Cipher.init(Cipher.java:1327) at encrypturl.Aes256.encrypt(Aes256.java:64)

mervick commented 5 years ago

On a default JDK installation, AES is limited to 128 bit key size. In order to perform 256-bit AES encryption, you will need to download and install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.

https://deveshsharmablogs.wordpress.com/2012/10/09/fixing-java-security-invalidkeyexception-illegal-key-size-exception/

mervick commented 5 years ago

https://www.andreafortuna.org/programming/java-tips-how-to-fix-the-invalidkeyexception-illegal-key-size-or-default-parameters-runtime/

afterbit01 commented 5 years ago

thank you! it works!