我想在 mycode 之后编写一个字节数组,它工作正常,但给出一个长大小的输出 newByteArray 我希望输出数组的大小应该是 16 是否可能
byte [] keyForEncription= new byte[16];
byte [] keyForDecription= new byte[16];
long FixedKey= 81985526925837671L;
long VariableKey=744818830;
for (int i1 = 0; i1 < 8; i1++)
{
keyForEncription[i1] = (byte)(FixedKey >> (8 * i1));
keyForEncription[i1 + 8] = (byte)(VariableKey >> (8 * i1));
}
byte[] data = new byte[255];
data[0]= 2;
data[1]= 0;
data[2]= 0;
data[3]= 0;
data[4]= 0;
data[5]= 6;
data[6]= 6;
data[7]= 81;
data[8]= 124;
data[9]= 123;
data[10]= 123;
data[11]= 12;
data[12]= 3;
data[13]= 27;
data[15]= 12;
data[16]= 0;
data[17]= 0;
data[18]= 0;
data[19]= 0;
System.out.println("Original byte Array : " +Arrays.toString(data));
SecretKeySpec skeySpec = new SecretKeySpec(keyForEncription, "AES");
Cipher cipher1 = Cipher.getInstance("AES/ECB/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] newByteArray = new byte[data.length];
newByteArray = cipher.doFinal(byteArray);
System.out.println("Encrypted Array : " +Arrays.toString(newByteArray));
这是输出加密数组: [110, -118, -119, -88, 73, -118, 57, 15, -52, -78, 100, 104, 102, -42, -102, -45, - 50, -116, -47, -53, 103, -40, -61, 62, 42, 15, -124, 98, -28, -77, 94, 78, -50, -116, -47, - 53、103、-40、-61、62、42、15、-124、98、-28、-77、94、78、-50、-116、-47、-53、103、-40、-61 , 62, 42, 15, -124, 98, -28, -77, 94, 78, -50, -116, -47, -53, 103, -40, -61, 62, 42, 15, -124 , 98, -28, -77, 94, 78, -50, -116, -47, -53, 103, -40, -61, 62, 42, 15, -124, 98, -28, -77, 94, 78]