尝试使用AES解码消息时,出现java.security.InvalidKeyException: Parameters missing
错误。这是我的密码初始化代码
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
密钥生成如下
MessageDigest sha = MessageDigest.getInstance("SHA-1");
byte[] bytes = passwordString.getBytes(StandardCharsets.UTF_8);
bytes = sha.digest(bytes);
bytes = Arrays.copyOf(bytes, 16);
SecretKeySpec key = new SecretKeySpec(bytes, "AES");
此错误仅在解密邮件时发生。加密工作正常。