1 00:00:00,480 --> 00:00:07,380 Welcome to the next session in Python Hacking, that is about decrypting with the transposition cipher, 2 00:00:07,710 --> 00:00:13,980 not unlike the seasonal cipher, the decryption process of a transposition cipher is also different 3 00:00:14,070 --> 00:00:15,550 from an encryption process. 4 00:00:15,870 --> 00:00:22,140 So in this session, we will create another program which will be for decrypting the transposition cipher 5 00:00:22,440 --> 00:00:23,940 to handle the decryption. 6 00:00:24,330 --> 00:00:31,500 Also with that, we would be covering the ground, might not see my daughter law functions also and 7 00:00:31,500 --> 00:00:33,240 then or boolean operators. 8 00:00:33,240 --> 00:00:41,010 And the truth will now come to how to decrypt with the transposition cipher manually, as we had done 9 00:00:41,250 --> 00:00:44,460 manually the encryption part in the Excel format. 10 00:00:44,700 --> 00:00:48,350 We would also do it in the decryption format also. 11 00:00:48,690 --> 00:00:57,600 So the text that we have supposed to decrypt is this that we had already encrypted now before step is 12 00:00:57,600 --> 00:01:04,770 to be for decrypting is the way to calculate the number of boxes that need to be drawn now for determining 13 00:01:04,770 --> 00:01:05,450 this number. 14 00:01:05,790 --> 00:01:11,940 They must be dividing the length of the cipher text message by Olcay and rounded up to the nearest whole 15 00:01:11,940 --> 00:01:14,660 number if it is not an unknown number already. 16 00:01:14,750 --> 00:01:21,420 OK, so the length of the ciphertext that we have is basically 30 and the key that we have used is also 17 00:01:21,420 --> 00:01:21,700 eight. 18 00:01:22,050 --> 00:01:26,100 So if we divide 30 by eight, we get three point seventy five. 19 00:01:26,340 --> 00:01:29,010 So rounding up three point seventy five will come before. 20 00:01:29,490 --> 00:01:31,710 So you'll have to draw the grid. 21 00:01:31,770 --> 00:01:35,320 That is four columns and each column will have eight. 22 00:01:35,550 --> 00:01:36,220 That is the key. 23 00:01:36,690 --> 00:01:44,250 So you also need to calculate the number of boxes which you have to shade, and that is using the total 24 00:01:44,250 --> 00:01:45,680 number of 32 boxes. 25 00:01:45,990 --> 00:01:48,220 So there is a track the length of the ciphertext. 26 00:01:48,220 --> 00:01:49,620 So that is 30 to minus 30. 27 00:01:49,620 --> 00:01:55,970 That is to follow the shade of the bottom two boxes in the rightmost column would be shaded. 28 00:01:56,430 --> 00:02:02,520 So you will have to then start filling up the boxes, placing one of the ciphertext in each box, starting 29 00:02:02,520 --> 00:02:07,470 at the top left the filling towards the right, as you did when you were encrypting it. 30 00:02:07,770 --> 00:02:14,130 So, for example, now let's say we are drawing here three, four, five, six, seven, eight. 31 00:02:14,650 --> 00:02:22,620 Now, let us just make this and also we will increase the length of it. 32 00:02:26,670 --> 00:02:27,030 But. 33 00:02:30,670 --> 00:02:35,720 And now what we do is we start adding up these characters one by one. 34 00:02:36,280 --> 00:02:38,590 So the first one that we have is. 35 00:02:39,990 --> 00:02:44,520 Also, we will just increase the font size here. 36 00:02:45,780 --> 00:02:48,000 Now let's go on adding it one by one. 37 00:02:48,360 --> 00:02:51,780 Does the first character first, then who? 38 00:02:52,470 --> 00:02:55,390 S then become below it is white. 39 00:02:56,160 --> 00:02:58,980 See you as. 40 00:03:01,910 --> 00:03:04,420 Now, let's just check this again. 41 00:03:04,560 --> 00:03:20,330 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 42 00:03:20,330 --> 00:03:21,230 48 hours. 43 00:03:21,260 --> 00:03:38,610 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. 44 00:03:39,640 --> 00:03:43,360 So here we would be filling up with this character. 45 00:03:44,180 --> 00:03:55,310 So you have your own space, then you have their dot, then you have M, A, C, E, then again you 46 00:03:55,310 --> 00:03:58,430 have there the character in all your. 47 00:03:58,430 --> 00:04:00,740 Also we have used three characters. 48 00:04:01,550 --> 00:04:02,090 Yes. 49 00:04:03,820 --> 00:04:07,320 Now, this is just a blank or the last pipeline symbol there. 50 00:04:07,660 --> 00:04:09,760 So what we'll do is we will. 51 00:04:10,850 --> 00:04:12,160 We have made some mistakes. 52 00:04:12,180 --> 00:04:14,060 You know, this is a single year. 53 00:04:14,230 --> 00:04:16,590 Also, we have used it here. 54 00:04:16,760 --> 00:04:25,940 We would also have, again, a space that this is also seen now here we would be having seen we are 55 00:04:25,940 --> 00:04:29,960 supposed to leave the next two blocks as blank. 56 00:04:30,350 --> 00:04:38,330 So let us have the edge or we would have a two edge then. 57 00:04:38,480 --> 00:04:38,910 See? 58 00:04:39,140 --> 00:04:43,090 And so these two, we would be insulting. 59 00:04:43,100 --> 00:04:44,610 It is like the last one. 60 00:04:45,230 --> 00:04:49,420 So now in this vein, this is correct, because after this, we have one space. 61 00:04:49,420 --> 00:04:51,250 So we have insulted the space character. 62 00:04:51,530 --> 00:04:59,780 We have a full stop after which we are having that again, full value for space, then M, x, c, e. 63 00:05:00,200 --> 00:05:01,380 So after this. 64 00:05:01,430 --> 00:05:05,530 Now, this is how we have basically used it for decrypting. 65 00:05:05,690 --> 00:05:11,750 And now if you notice over here, let us write down the first character that we have. 66 00:05:12,020 --> 00:05:16,640 Sipi via the h o n space H. 67 00:05:17,120 --> 00:05:18,860 Then in the next one, what do you have. 68 00:05:18,860 --> 00:05:32,630 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 69 00:05:32,780 --> 00:05:33,440 full stop. 70 00:05:34,130 --> 00:05:36,750 That is what if you combine that together. 71 00:05:37,190 --> 00:05:40,310 Suppose that's right down over here. 72 00:05:40,310 --> 00:05:48,980 Vitan H a c g c or you are a c ss eight G bottom. 73 00:05:49,640 --> 00:05:53,060 That's how we have again decrypted the message. 74 00:05:53,480 --> 00:05:59,540 So via encrypting it is in a horizontal way while decrypting it is in the vertical. 75 00:05:59,620 --> 00:06:03,230 We saw a quick recap to the step for decrypting. 76 00:06:03,470 --> 00:06:08,990 One is calculate the number of columns you need by dividing the length of the message by the key and 77 00:06:08,990 --> 00:06:09,900 then rounding it up. 78 00:06:10,160 --> 00:06:14,240 Second, this drop oxygen column and rolls use number of columns. 79 00:06:14,240 --> 00:06:20,780 You calculate that in the first step and the number of rules as the same as the E number three is calculate 80 00:06:20,780 --> 00:06:24,200 the number of boxes crocheted by picnicked open number of boxes. 81 00:06:24,440 --> 00:06:31,430 That is subtracting the length of the ciphertext with the length of the normal key that you have next 82 00:06:31,430 --> 00:06:37,550 is shaded the number of boxes you calculated in the earlier step at the bottom of the rightmost column, 83 00:06:37,940 --> 00:06:43,640 then start filling up the correct dose of the ciphertext starting at the top row and going from left 84 00:06:43,640 --> 00:06:44,090 to right. 85 00:06:44,360 --> 00:06:46,220 Skip any of the shaded boxes. 86 00:06:46,520 --> 00:06:51,890 You will get a plaintext by reading the leftmost column from the top to bottom and continuing to do 87 00:06:51,950 --> 00:06:53,150 so in each of the column. 88 00:06:53,540 --> 00:06:59,870 So note that if you have used a different key, you will draw the wrong number of rules even if you 89 00:06:59,870 --> 00:07:02,210 follow the other step and decryption process. 90 00:07:02,330 --> 00:07:05,870 Correcting the plaintext would be random garbage. 91 00:07:06,230 --> 00:07:09,960 Similarly, as you would use for a Ronke, we don't see the Saiful. 92 00:07:10,340 --> 00:07:11,420 Now let us write down. 93 00:07:11,750 --> 00:07:14,980 So score for this transposition decryption program. 94 00:07:15,500 --> 00:07:20,060 So for that, let's go back to our financial and. 95 00:07:21,160 --> 00:07:22,220 Create a new fight. 96 00:07:22,690 --> 00:07:29,920 Now, the first thing is we need to also import Matt Antiplatelet so we will see first import Matt Gunma, 97 00:07:32,350 --> 00:07:37,540 then we would define again mean here and we would have my. 98 00:07:38,560 --> 00:07:46,300 Message a star now that's equal to we will take down the encrypted text, which is there as it does 99 00:07:46,720 --> 00:07:48,640 so let's put it here. 100 00:07:50,020 --> 00:07:53,680 And after this, let's remove the pipeline symbol here. 101 00:07:53,690 --> 00:07:57,550 We will define my first year and that's equal to also it. 102 00:07:58,180 --> 00:08:03,700 Then we will take your plain text SDR, which is for our friend. 103 00:08:04,510 --> 00:08:10,900 Now, here we would be creating the decrypt message SDR method. 104 00:08:11,260 --> 00:08:14,260 Here we would pass Mixter and. 105 00:08:16,060 --> 00:08:21,340 My message is clear, and whatever the value is written, that is what we are storing in plain text, 106 00:08:22,390 --> 00:08:27,730 then we would be printing that again, plain text SDR. 107 00:08:28,980 --> 00:08:33,390 But concatenating on pipeline symbol. 108 00:08:35,960 --> 00:08:44,780 After which we also see people clip, don't use the copy metal and copy the plain text still. 109 00:08:45,710 --> 00:08:54,920 Now after this this method and all of your and we the next method that is decrypt message start, which 110 00:08:54,920 --> 00:08:58,670 takes the Gasteyer and the messages. 111 00:08:59,210 --> 00:09:06,650 And inside this particular function that we have now, the transposition decrypt function will basically 112 00:09:06,800 --> 00:09:12,290 simulate the columns and the rules of the grid that the plain text is written on by using a list of 113 00:09:12,290 --> 00:09:12,880 strings. 114 00:09:13,130 --> 00:09:18,780 So first we need to calculate a few values, the number of columns in our transposition grid. 115 00:09:19,190 --> 00:09:21,530 So for that, we will take a number of. 116 00:09:23,550 --> 00:09:32,730 Columns that's equal to be converted to integer using my God seal, and he'll be past the length of 117 00:09:32,730 --> 00:09:40,800 our message, a star divided by converting to float the value of KSTU.