AES Encryption Java Invalid Key length

后端 未结 5 1636
甜味超标
甜味超标 2020-12-30 10:23

I am trying to create an AES encryption method, but for some reason I keep getting

java.security.InvalidKeyException: Key length not 128/192/256

5条回答
  •  隐瞒了意图╮
    2020-12-30 10:52

    You can install the JCE Unlimited Strength jars, as is suggested on several other similar questions, or just try including this code in your main function or driver.

    try {
        java.lang.reflect.Field field = Class.forName("javax.crypto.JceSecurity").getDeclaredField("isRestricted");
        field.setAccessible(true);
        field.set(null, java.lang.Boolean.FALSE);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    

提交回复
热议问题