Bab
Bab

Reputation: 443

How to print the values of each column in a matrix?

I have a nested for loop where I call some different methods. These methods need to be called in the sequence I have set as I trying to work with Rainbow tables.

So, I have a for loop, which generates a 3 bytes key - This is column 0 Inside this for loop, I have another for loop which encrypts some data with AES and then restricts the output to 3 bytes - AES-128 requires at least 16 bytes keys, so the last 13 bytes are 0

What I need help with is NOT cryptology, but how to print each column in each row with the set up of for loops.

What I want to achieve is to count the number of unique values in each column.

    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
        }

EDIT: Basically what I am asking is how I can print all the ROWS in each column, and not each column in each row. Sorry for misformulation

Example Input:

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 };

Upvotes: 1

Views: 172

Answers (1)

Mohammad Aziz Nabizada
Mohammad Aziz Nabizada

Reputation: 468

This code write rows of matrix in columns. Read every column and write in row of matrix.

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(); 
}

Upvotes: 3

Related Questions