3
我想使用192位密钥加密数据。Android AES crypt 192bit密钥
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());
}
但加密是不正确的。而且每次数组的内容都不一样。为什么?
您对“不正确”是什么意思? –
您如何初始化您的KeyGenerator? –
>>你的意思是“不正确” 加密结果与C++中的加密结果不同 >>你如何初始化你的KeyGenerator? 我没有生成密钥。 –