我很累人地将encription逻辑转换成用C#编写的java。我传递一个自定义IV作为参数。通过传递IV加密AES 256
private static byte[] iv = new byte[] { 116,209,63,154,85,66,37,82,96,104,131,192,103,140,125,176 };
但是,在java中,不能在一个字节数组中保存多于128个。在C#中是可能的。
this.secretKeySpec = new SecretKeySpec(key, "AES");
this.iv = new IvParameterSpec(iv);
this.cipher = Cipher.getInstance(ALGORITHM_AES256);
在javax.crypto中,IvParameterSpec constactory只允许字节数组为“iv”。任何人都可以请帮助传递上面的byte []作为iv参数在Java中。
[similar](http://stackoverflow.com/questions/2346101/java-how-to-use-byte-literals-greater-than-0x7f)[questions](http://stackoverflow.com/questions/9241336/initialize-unsigned-byte-array-using-hex-number)可能被认为是重复的。 –
您不应该首先使用静态IV。静态IV是无用的。 –