我有一个嵌套的 for 循环,我在其中调用一些不同的方法。这些方法需要按照我在尝试使用 Rainbow 表时设置的顺序调用。
所以,我有一个 for 循环,它生成一个 3 字节的 key - 这是第 0 列 在这个 for 循环中,我有另一个 for 循环,它使用 AES 加密一些数据,然后将输出限制为 3 个字节 - AES-128 需要至少 16 个字节的 key ,因此最后 13 个字节是 0
我需要的帮助不是密码学,而是如何通过设置 for 循环来打印每行中的每一列。
我想要实现的是计算每列中唯一值的数量。
DecimalFormat df = new DecimalFormat(".##");
for (int i = 0; i < 6; i++) {
gKey(); // generates random 3 bytes
for (int j = 1; j < 6; j++) {
aesResult = aes.encrypt(keySet); // encrypts with 16 bytes keya and fixed plaintext, where the key's first 3 bytes are randomly generated the first time
reduction(aesResult, j); // restricting the output
System.out.println("Covered points "+ kStore); // kStore is a HashSet - I chose to use that as it is not allowed to have duplicates in HashSet. I basically store the keys in this HashSet in the reduction method
}
编辑: 基本上我要问的是如何打印每列中的所有行,而不是每行中的每一列。抱歉,表述错误
示例 输入:
byte[] keySet= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte plaintext[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd, (byte) 0xee, (byte) 0xff };
最佳答案
此代码将矩阵的行写入列中。读取矩阵的每一列并写入矩阵的行。
int [][] arr=new int[6][6];
for(int i = 0; i < arr.length; i++) {
for(int j = 0; j < arr.length; j++) {
System.out.print(arr[j][i]+" ");
}
System.out.println();
}
关于java - 如何打印矩阵中每一列的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53256088/