Welcome to the next session in Python Hacking, that is about decrypting with the transposition cipher,
not unlike the seasonal cipher, the decryption process of a transposition cipher is also different
from an encryption process.
So in this session, we will create another program which will be for decrypting the transposition cipher
to handle the decryption.
Also with that, we would be covering the ground, might not see my daughter law functions also and
then or boolean operators.
And the truth will now come to how to decrypt with the transposition cipher manually, as we had done
manually the encryption part in the Excel format.
We would also do it in the decryption format also.
So the text that we have supposed to decrypt is this that we had already encrypted now before step is
to be for decrypting is the way to calculate the number of boxes that need to be drawn now for determining
this number.
They must be dividing the length of the cipher text message by Olcay and rounded up to the nearest whole
number if it is not an unknown number already.
OK, so the length of the ciphertext that we have is basically 30 and the key that we have used is also
eight.
So if we divide 30 by eight, we get three point seventy five.
So rounding up three point seventy five will come before.
So you'll have to draw the grid.
That is four columns and each column will have eight.
That is the key.
So you also need to calculate the number of boxes which you have to shade, and that is using the total
number of 32 boxes.
So there is a track the length of the ciphertext.
So that is 30 to minus 30.
That is to follow the shade of the bottom two boxes in the rightmost column would be shaded.
So you will have to then start filling up the boxes, placing one of the ciphertext in each box, starting
at the top left the filling towards the right, as you did when you were encrypting it.
So, for example, now let's say we are drawing here three, four, five, six, seven, eight.
Now, let us just make this and also we will increase the length of it.
But.
And now what we do is we start adding up these characters one by one.
So the first one that we have is.
Also, we will just increase the font size here.
Now let's go on adding it one by one.
Does the first character first, then who?
S then become below it is white.
See you as.
Now, let's just check this again.
It being or as it is why I see you asked at stake are a so dusty OK then we have until for the next
48 hours.
It is agi s g i s g then you home and E E again and G now wherever you would be having their spaces.
So here we would be filling up with this character.
So you have your own space, then you have their dot, then you have M, A, C, E, then again you
have there the character in all your.
Also we have used three characters.
Yes.
Now, this is just a blank or the last pipeline symbol there.
So what we'll do is we will.
We have made some mistakes.
You know, this is a single year.
Also, we have used it here.
We would also have, again, a space that this is also seen now here we would be having seen we are
supposed to leave the next two blocks as blank.
So let us have the edge or we would have a two edge then.
See?
And so these two, we would be insulting.
It is like the last one.
So now in this vein, this is correct, because after this, we have one space.
So we have insulted the space character.
We have a full stop after which we are having that again, full value for space, then M, x, c, e.
So after this.
Now, this is how we have basically used it for decrypting.
And now if you notice over here, let us write down the first character that we have.
Sipi via the h o n space H.
Then in the next one, what do you have.
It is a C and G space C then what do you have or you are s e space m e and then the last one ss a ge
full stop.
That is what if you combine that together.
Suppose that's right down over here.
Vitan H a c g c or you are a c ss eight G bottom.
That's how we have again decrypted the message.
So via encrypting it is in a horizontal way while decrypting it is in the vertical.
We saw a quick recap to the step for decrypting.
One is calculate the number of columns you need by dividing the length of the message by the key and
then rounding it up.
Second, this drop oxygen column and rolls use number of columns.
You calculate that in the first step and the number of rules as the same as the E number three is calculate
the number of boxes crocheted by picnicked open number of boxes.
That is subtracting the length of the ciphertext with the length of the normal key that you have next
is shaded the number of boxes you calculated in the earlier step at the bottom of the rightmost column,
then start filling up the correct dose of the ciphertext starting at the top row and going from left
to right.
Skip any of the shaded boxes.
You will get a plaintext by reading the leftmost column from the top to bottom and continuing to do
so in each of the column.
So note that if you have used a different key, you will draw the wrong number of rules even if you
follow the other step and decryption process.
Correcting the plaintext would be random garbage.
Similarly, as you would use for a Ronke, we don't see the Saiful.
Now let us write down.
So score for this transposition decryption program.
So for that, let's go back to our financial and.
Create a new fight.
Now, the first thing is we need to also import Matt Antiplatelet so we will see first import Matt Gunma,
then we would define again mean here and we would have my.
Message a star now that's equal to we will take down the encrypted text, which is there as it does
so let's put it here.
And after this, let's remove the pipeline symbol here.
We will define my first year and that's equal to also it.
Then we will take your plain text SDR, which is for our friend.
Now, here we would be creating the decrypt message SDR method.
Here we would pass Mixter and.
My message is clear, and whatever the value is written, that is what we are storing in plain text,
then we would be printing that again, plain text SDR.
But concatenating on pipeline symbol.
After which we also see people clip, don't use the copy metal and copy the plain text still.
Now after this this method and all of your and we the next method that is decrypt message start, which
takes the Gasteyer and the messages.
And inside this particular function that we have now, the transposition decrypt function will basically
simulate the columns and the rules of the grid that the plain text is written on by using a list of
strings.
So first we need to calculate a few values, the number of columns in our transposition grid.
So for that, we will take a number of.
Columns that's equal to be converted to integer using my God seal, and he'll be past the length of
our message, a star divided by converting to float the value of KSTU.