1 00:00:00,580 --> 00:00:07,800 So now coming to getting the hacked message and using over here the hack transposition cipher function, 2 00:00:08,320 --> 00:00:10,930 we start with a couple of print statements there. 3 00:00:11,710 --> 00:00:19,330 That is, we are seeing print hacking, then printing press control on windows or accountability on 4 00:00:19,330 --> 00:00:23,760 Mac OS and Linux to quit at any time after this. 5 00:00:23,770 --> 00:00:30,580 Now, because the program may try many keys and the program displays a message telling the user that 6 00:00:30,580 --> 00:00:35,500 the hacking has started and that it might take a moment to finish the process. 7 00:00:35,890 --> 00:00:43,720 So the print command over here is the user to losing on Windows of the old Linux or OS to exit the program 8 00:00:43,720 --> 00:00:44,380 at any point. 9 00:00:45,110 --> 00:00:51,760 You can actually press this to exit any running Python program on the particular given operating system. 10 00:00:52,090 --> 00:00:58,120 And after that, the next couple of lines tells the program which key to loop through by specifying 11 00:00:58,120 --> 00:01:01,150 the range of possibilities for the transposition cipher. 12 00:01:01,630 --> 00:01:08,440 So over here, we run this for loop after that, saying for a start in the range of one till the length 13 00:01:08,470 --> 00:01:14,530 of the messages we are saying print drying the key and the number of the key that it is trying. 14 00:01:14,950 --> 00:01:19,770 So the possible keys for the transposition cipher range between one and the length of the message. 15 00:01:19,780 --> 00:01:26,380 OK, and the for loop on this particular line, there is the hacking part of the function which with 16 00:01:26,380 --> 00:01:28,050 each of these particular given keys. 17 00:01:28,570 --> 00:01:35,200 So it uses the string interpolation to print the key currently being tested, using the string interpolation 18 00:01:35,200 --> 00:01:38,060 to provide a feedback back to the user. 19 00:01:38,290 --> 00:01:46,990 So using the message that this or using the function that is Demo 16 dot decrypt the message which is 20 00:01:46,990 --> 00:01:53,140 there in our Demo 16 Lopevi program that we have already written, it gets the decrypted output from 21 00:01:53,140 --> 00:01:59,280 the current key being tested and stores that particular value in the variable that is decrypted next 22 00:01:59,590 --> 00:01:59,860 year. 23 00:02:00,490 --> 00:02:06,190 And the decrypted output in the particular variable encrypted text is still will be English. 24 00:02:06,190 --> 00:02:08,140 Only of the current equals you. 25 00:02:08,530 --> 00:02:11,210 Otherwise it would appear as the garbage to. 26 00:02:11,650 --> 00:02:19,930 So then the program passes that particular string or that is decrypted next year into his English check 27 00:02:19,930 --> 00:02:24,080 function, which is there in our English, not by OK. 28 00:02:24,550 --> 00:02:31,180 And then it is part of the decrypted text Asgeir the key use and the instructions for the user, that 29 00:02:31,180 --> 00:02:39,160 is, it asks for a blank line put in the possible encryption hack, but is the key again a blank line 30 00:02:39,160 --> 00:02:46,690 and then asked for the response from the user by asking you to press the if it is done now does because 31 00:02:46,690 --> 00:02:53,680 the chicken is English check method written through and move the execution to the next line. 32 00:02:53,680 --> 00:02:56,200 It doesn't mean that the program has found the correct. 33 00:02:56,380 --> 00:03:03,940 It could be a false positive, meaning that the program dictated some text as English that is actually 34 00:03:03,940 --> 00:03:10,570 a garbage did so to make sure that it reveals the text so the user can confirm that the text isn't in 35 00:03:10,750 --> 00:03:13,680 English, it uses that decrypt. 36 00:03:13,720 --> 00:03:20,500 The text is still calling for free to print out the first 50 characters of the day, and then the program 37 00:03:20,500 --> 00:03:27,100 pauses after the particular line and ask for or wait for the user to enter the or anything else. 38 00:03:27,400 --> 00:03:35,080 And then stores that input as a string in the given responsibility, not understanding the strip string 39 00:03:35,230 --> 00:03:35,410 method. 40 00:03:35,900 --> 00:03:40,840 A program gives a user specific instruction, but the user doesn't follow them. 41 00:03:40,840 --> 00:03:41,410 Exactly. 42 00:03:41,410 --> 00:03:42,580 And error results. 43 00:03:42,640 --> 00:03:49,480 And when of a particular program prompts the user to enter the form the hacked message, it means that 44 00:03:49,480 --> 00:03:56,710 the program won't accept any input other than the end of the user and does an extra space or character 45 00:03:56,710 --> 00:03:59,390 along with the the program won't accept. 46 00:03:59,890 --> 00:04:07,630 So let us look at how to use this strip string method to make the program accept other inputs as long 47 00:04:07,630 --> 00:04:10,330 as they are similar enough to be so. 48 00:04:10,330 --> 00:04:17,980 The strip string method returns a version of the string with any whitespace characters at the beginning 49 00:04:17,980 --> 00:04:21,260 and end of the string stripped out now out. 50 00:04:21,400 --> 00:04:25,660 These characters are the space characters type characters and then you learn that. 51 00:04:26,260 --> 00:04:32,070 So for this we would enter some following text in the interactive shell to see how this basically works. 52 00:04:32,410 --> 00:04:39,790 So if we go over here and if we write down here a certain space right down, hello, and then we use 53 00:04:39,790 --> 00:04:43,780 the strip, still, we get only the text that is hello. 54 00:04:44,170 --> 00:04:49,960 Or if we write down using, say, some special characters, then. 55 00:04:53,770 --> 00:04:55,570 Dot strip. 56 00:04:56,470 --> 00:05:00,610 Still, it is coming the same way, or if we try to give space before 57 00:05:03,100 --> 00:05:12,220 OK and say here dot strip, not in between the words, the space will be counted, but before and after 58 00:05:12,220 --> 00:05:13,610 that would be removed. 59 00:05:14,620 --> 00:05:20,470 In the given examples over here, the strip method remove the space characters at the beginning, at 60 00:05:20,470 --> 00:05:22,940 the end of any given strength. 61 00:05:23,190 --> 00:05:29,470 OK, so if a particular string includes space at the beginning or at the end of the string, the metal 62 00:05:29,470 --> 00:05:34,660 remove them from the site but doesn't remove any space between other characters. 63 00:05:35,410 --> 00:05:43,000 The strip method can also have a string argument postulate that is a method to remove characters other 64 00:05:43,000 --> 00:05:46,480 than white space from the beginning and the end of the string. 65 00:05:46,840 --> 00:05:55,120 Not to see an example for this, say we give over here on the example C write down any characters or 66 00:05:55,210 --> 00:05:57,280 let's write on just one character in this case. 67 00:05:57,640 --> 00:06:00,430 See BP right down here. 68 00:06:00,460 --> 00:06:01,900 Hello, BP. 69 00:06:02,140 --> 00:06:04,300 OK, dot strip. 70 00:06:04,840 --> 00:06:08,230 And we give the character piece so it removes P from every bit. 71 00:06:08,830 --> 00:06:13,110 OK, or suppose we have used, say, a baby everywhere. 72 00:06:14,260 --> 00:06:16,720 This is our text we use here. 73 00:06:16,840 --> 00:06:18,870 Dot strip say a bit. 74 00:06:19,150 --> 00:06:21,780 So it removes a bit and gives us the given string. 75 00:06:22,360 --> 00:06:25,210 OK, like that we can give your example. 76 00:06:25,400 --> 00:06:32,560 OK so if you pass a string arguments the A or a B remove this characters when they occur at the beginning 77 00:06:32,560 --> 00:06:34,070 of the end of the string. 78 00:06:34,510 --> 00:06:39,850 Similarly, but that will give given strip function doesn't remove characters embedded in the middle 79 00:06:39,850 --> 00:06:40,450 of the string. 80 00:06:41,110 --> 00:06:42,160 So let us see. 81 00:06:42,160 --> 00:06:46,460 Applying the strip string method over in our given program here. 82 00:06:47,020 --> 00:06:51,770 Now let's return to this old school and see how to apply this drop in our given program. 83 00:06:52,210 --> 00:06:57,020 So after this, if we go below, OK, we are having this condition over here. 84 00:06:57,460 --> 00:07:03,670 Now, in this we are using the if the response starts stripped, talk about what starts with B now, 85 00:07:03,670 --> 00:07:09,910 if the condition for the statement or simply responds is equal to capitally, the user would have to 86 00:07:09,910 --> 00:07:11,120 enter capitally. 87 00:07:11,140 --> 00:07:11,860 Exactly. 88 00:07:12,040 --> 00:07:19,270 And nothing else to end the program, for example, of the user interface Molde or some spaces capitally 89 00:07:19,510 --> 00:07:25,330 or say the capitalised on the condition would be false and the program would continue checking other 90 00:07:25,330 --> 00:07:27,160 PS instead of returning the act. 91 00:07:28,000 --> 00:07:34,090 So to avoid this issue, the string and the response remove the white space from the start and the end 92 00:07:34,090 --> 00:07:35,980 of the string with the to strip. 93 00:07:36,310 --> 00:07:43,330 Then the string that the user response strip evaluates to has the method called on whether the user 94 00:07:43,330 --> 00:07:45,060 enters mouldy or capitally. 95 00:07:45,070 --> 00:07:51,220 The string return from the above will always be capitalized test capitally, so adding the flexibility 96 00:07:51,220 --> 00:07:57,910 in the type of the input the program can accept and make it easier to, you know, to make the program 97 00:07:57,910 --> 00:07:59,080 accept user input. 98 00:07:59,080 --> 00:08:03,130 That starts with the but it is Fullwood we can use. 99 00:08:03,130 --> 00:08:08,650 This starts to check only the, for example, of the user input space. 100 00:08:09,050 --> 00:08:10,340 The other response. 101 00:08:10,360 --> 00:08:14,290 Then the white space would be stripped and the string done would be passed to upper. 102 00:08:14,470 --> 00:08:20,260 After Apple capitalizes the whole string into capital, the string is then passed on to starts with, 103 00:08:20,260 --> 00:08:24,640 which returns the true because the string that starts with the substring B. 104 00:08:25,030 --> 00:08:31,060 Now, if the user indicates that the decrypted string is correct, the function we are to have transposition, 105 00:08:31,060 --> 00:08:32,830 Asscher will return. 106 00:08:32,830 --> 00:08:39,210 The decrypted text is still not failing to have the message, for example, of the first line of default 107 00:08:39,220 --> 00:08:43,030 loop that began over here in that is for Keirstead in the range. 108 00:08:43,300 --> 00:08:49,570 If that particular loop has begin and the program execution reaches this point, it means the program 109 00:08:49,570 --> 00:08:54,520 has never reached the written statement, which would happen if the correctly decrypted text was never 110 00:08:54,520 --> 00:08:57,130 found for any of the keys that would break. 111 00:08:57,160 --> 00:09:03,100 So in that case, it returns non-value to indicate the hacking has been OK. 112 00:09:03,430 --> 00:09:06,760 So after this, we come to the last part overfill. 113 00:09:06,770 --> 00:09:12,580 That is, we are checking OK, although the main function of this program was run by itself rather than 114 00:09:12,580 --> 00:09:18,120 being imported by another program using its high transposition SDR function. 115 00:09:18,790 --> 00:09:23,800 So remember that the name variable is said by Python and the main function will be will not we call 116 00:09:23,800 --> 00:09:29,530 it your current file that this transposition example is important as the module? 117 00:09:29,980 --> 00:09:35,080 OK, so with this, we have understood how the particular program has been created. 118 00:09:35,080 --> 00:09:40,410 How does it execute and what is the output that we are getting from the executed program?