Hey guys, I am trying to figure out how to do a double transposition cipher.
This is what I have so far to take in a string and then put that string a 2x2 array of a fixed size that I made. I have the key that I want to use for the new 2x2 array, but I don't know how to implement it. Any ideas to help me figure it out? I want to do the work on my own, but helpful hints could really help me out

void transPosition(string b)
{
    int key[7] = {4,3,1,2,5,6,7};
    //gives d the size of the key
    int d = sizeof(key) / sizeof(key[0]);

    char matrix[4][7];
    //this loop will put the string in a 2x2 char array
    for(unsigned int i = 0; i < b.length(); i++)
    {
        matrix[i/d][i%d] = b[i];
    }

//just to check, we use this loop
//to see if the array has the letters
//in order from the string
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 7; j++)
        {
            cout << matrix[i][j];
        }
        cout << endl;
    }
}

Here's a pretty good Article on how a Double Transposition Cipher works. The first thing you'll notice is that it requires 2 keys not just one.

I only need one key and let's say the plaintext is

{HELLOWO
 RLDWXYZ}

And the key is

{4,3,1,2,5,6,7}

The cipher text now looks like

 {LDLWELH
  ROXWYOZ}

And then we would do that a second time with the same key.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.