Decrypting error : “no iv set when one expected”

后端 未结 1 1010
抹茶落季
抹茶落季 2020-12-30 07:52

I\'m almost new to encryption.

I am trying to decrypt an array of bytes, and when I am providing the IV I am getting an exception : InvalidAlgorithmParameterExceptio

相关标签:
1条回答
  • Solved.

    I was using a wrong SecretKey, not the one you can create for AES.

    Previously I had :

    KeySpec spec = new PBEKeySpec(password.toCharArray(), encryptionKeySalt, 12345,256);
    SecretKey encriptionKey = factory.generateSecret(spec);
    

    which creates a JCEPBEKey.

    I was missing :

    Key encriptionKey = new SecretKeySpec(encriptionKey.getEncoded(), "AES"); 
    

    which creates an appropiate key for AES.

    0 讨论(0)
提交回复
热议问题