我想使用一个192位密钥来加密数据。
SecretKeySpec key = new SecretKeySpec(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, "AES/CBC/NoPadding");
byte[] data = new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
byte[] encrypted = null;
try {
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key);
encrypted = cipher.doFinal(data);
} catch (Exception e) {
System.out.println(e.getMessage());
}
但加密并不是真正的。而且每次数组的内容都不同。为什么?