JAVA-043 / 中级
使用 ECB 模式或 DES 加密
为什么存在问题?
暴露数据模式或密钥长度不足。
如何修复
java
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
byte[] iv = new byte[12]; new SecureRandom().nextBytes(iv); // 每次使用新 IV
c.init(Cipher.ENCRYPT_MODE, key, new GCMParameterSpec(128, iv));