Use a dynamically-generated, random IV

Hi Sebastián and welcome to the community!

Your code looks indeed fine. The IV should only be randomly generated when encrypting but of course for the decrypting part that is not possible, since it has to match the IV that was used for encrypting.

In some cases it is not easily possible for us to determine if the code will encrypt or decrypt but in this case it should be no problem. I have created the ticket SONARJAVA-4122 to fix the issue. Thanks for the report!

1 Like