JAVA-043 / Intermediate
Using ECB mode or DES encryption
Why is this a problem?
Exposes patterns or uses insufficient key length.
How to fix it
java
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
byte[] iv = new byte[12]; new SecureRandom().nextBytes(iv); // New IV every time
c.init(Cipher.ENCRYPT_MODE, key, new GCMParameterSpec(128, iv));