1 00:00:00,330 --> 00:00:07,680 Welcome to the first session in a row by phone hacking, intermediate level court now in the last course 2 00:00:07,680 --> 00:00:15,930 of in the last session, we have used the transpositions file Saiful to encrypt and decrypt the entire 3 00:00:15,930 --> 00:00:24,180 file, but we haven't tried writing a brute force program to decipher no messages encrypted with the 4 00:00:24,180 --> 00:00:25,390 transposition file. 5 00:00:25,390 --> 00:00:32,700 A cipher can have thousands of possibilities, which your computer can still easily brute force, but 6 00:00:33,060 --> 00:00:38,670 you would then have to look through thousands of descriptions to find the one correct plaintext. 7 00:00:39,300 --> 00:00:41,880 Now, as you can imagine, this can be a big problem. 8 00:00:42,270 --> 00:00:44,430 But there is a workaround for this. 9 00:00:44,850 --> 00:00:51,230 When the computer decrypt the message using the Ronke, the resulting string is garbage text. 10 00:00:51,240 --> 00:00:58,920 Instead of a normal English text, we can basically programmed the computer to recognize when or decrypted 11 00:00:58,920 --> 00:01:06,930 messages English that we if the computer decrypts using the Ronke, it goes on and tries the next possible 12 00:01:06,930 --> 00:01:07,320 case. 13 00:01:07,770 --> 00:01:14,250 Eventually when the computer dries up the decrypts to English text, it can then stop and bring that 14 00:01:14,460 --> 00:01:20,290 to your attention, sparing you from having to look through thousands of incorrect descriptions. 15 00:01:20,970 --> 00:01:24,960 So basically, let us see, how can a computer understand English? 16 00:01:25,800 --> 00:01:32,250 Now, basically a computer can't understand English, at least not in the way that human beings understand. 17 00:01:32,700 --> 00:01:39,930 Now, computers don't understand even math, chess or human rebellion's either any more than a clock 18 00:01:39,930 --> 00:01:41,560 understands lunchtime. 19 00:01:42,060 --> 00:01:46,140 So computer just executes the instructions one after another. 20 00:01:46,590 --> 00:01:54,630 But these instructions can mimic complex behaviours to solve the math problems when the chips are down. 21 00:01:54,630 --> 00:01:56,880 The future leader of a human resistance. 22 00:01:57,240 --> 00:02:03,000 Ideally, when we need to create a python function, for example, is English function. 23 00:02:03,330 --> 00:02:10,220 That is, we can pass a string to it and get a written value through if the string is English or force 24 00:02:10,320 --> 00:02:14,490 if it's some random or gibberish in that particular case. 25 00:02:14,760 --> 00:02:20,970 So let us look at some English text and some garbage text to see what patterns they might have. 26 00:02:21,450 --> 00:02:27,030 Now, for example, if we type something like C Python's R. 27 00:02:27,890 --> 00:02:34,250 Your friends, OK, or if you type something like instead of this. 28 00:02:40,170 --> 00:02:43,500 Now, this is not what a human can read, right? 29 00:02:43,530 --> 00:02:49,620 I notice that the English text is basically made up of words that you would find in a dictionary, but 30 00:02:49,860 --> 00:02:55,260 the garbage text isn't because votes are usually separated by spaces. 31 00:02:55,530 --> 00:03:00,750 One way of checking whether a message string is English is to split the message into smaller strings 32 00:03:01,020 --> 00:03:08,310 at each space and check whether each string is a dictionary word to split the message string into some 33 00:03:08,310 --> 00:03:08,720 strings. 34 00:03:08,730 --> 00:03:15,930 We can use the python string method name that is split when checks where each word begins and ends by 35 00:03:15,930 --> 00:03:18,750 looking for spaces between the characters. 36 00:03:19,020 --> 00:03:25,290 Right now we can then compare each substring to each word in the dictionary using an if statement. 37 00:03:25,830 --> 00:03:28,980 OK, now we would all like that. 38 00:03:28,980 --> 00:03:33,300 We would probably wouldn't because it would be tedious to type all of it. 39 00:03:33,780 --> 00:03:40,890 And fortunately we can use the English dictionary files, which are basically text files that contain 40 00:03:40,890 --> 00:03:46,170 nearly every word in English that basically will provide you with a dictionary file, which you can 41 00:03:46,170 --> 00:03:46,490 use. 42 00:03:46,520 --> 00:03:49,080 So we just need to write down the function. 43 00:03:49,080 --> 00:03:55,560 For example, it is English function that checks without a substring is a message or a particular substance 44 00:03:55,560 --> 00:03:58,710 available in the messages are in a dictionary file. 45 00:03:59,370 --> 00:04:02,100 So not every word exists in our dictionary. 46 00:04:02,100 --> 00:04:04,180 Dictionary files might be incomplete. 47 00:04:04,500 --> 00:04:10,890 For example, it might have the word names it all, but there are some perfectly good descriptions that 48 00:04:10,890 --> 00:04:17,760 might have non English words in there, like, for example, Xavi w six eight six in s, for example, 49 00:04:17,760 --> 00:04:18,300 like this. 50 00:04:18,810 --> 00:04:25,050 OK, so a plain text could also be in a different language, but will assume it's in English now. 51 00:04:25,620 --> 00:04:27,850 So we would write down it is English function. 52 00:04:28,230 --> 00:04:32,030 OK, that won't be foolproof obviously, but we will give it a try. 53 00:04:32,280 --> 00:04:39,720 And now there is a low probability that a ciphertext that is decrypted using the Ronke will decrypt 54 00:04:39,720 --> 00:04:40,350 to English. 55 00:04:40,750 --> 00:04:47,000 OK, now first thing is we will download a dictionary file for this which we already have created. 56 00:04:47,250 --> 00:04:52,410 And it's basically a text file which is having one word for line in the uppercase. 57 00:04:52,710 --> 00:04:56,910 OK, now we would just add it or and I'll show you after opening it. 58 00:04:57,150 --> 00:04:58,360 All votes do we have. 59 00:04:58,710 --> 00:04:59,800 So let's remove it. 60 00:05:00,300 --> 00:05:06,630 Now, if you go to a drive, we have a folder as an intermediate level where we have created this dictionary 61 00:05:06,630 --> 00:05:13,950 file, which is having one more power line, all in capital, having some English words stored in the 62 00:05:14,460 --> 00:05:14,810 file. 63 00:05:14,880 --> 00:05:18,060 This is basically able to find them dictionary dot the exchange. 64 00:05:18,420 --> 00:05:24,180 Now, we would create a function named is English OK, which will basically split a decrypted string 65 00:05:24,180 --> 00:05:29,980 into individual sub strings and check whether each substring exist as a word in the dictionary. 66 00:05:30,630 --> 00:05:36,420 And if a certain number of such strings of English words will identify that text as English, and if 67 00:05:36,420 --> 00:05:42,120 the text is in English, there's a good chance that will have successfully decrypted a ciphertext with 68 00:05:42,120 --> 00:05:42,900 the correct. 69 00:05:43,590 --> 00:05:47,790 So now we would write down the source code for the English module. 70 00:05:48,090 --> 00:05:51,180 OK, we'll create a new file and write down the code and do it. 71 00:05:52,090 --> 00:06:03,730 OK, so we will create file new file and we will create Sea of Letters this year and we will give all 72 00:06:03,730 --> 00:06:08,300 the letters and packages a, b, c, d, e, f, g, h, i, j, k, l. 73 00:06:08,560 --> 00:06:13,210 And many of you oreste, youve w, x, y, z. 74 00:06:14,110 --> 00:06:22,930 After this, we would create another constant letter and space esteve and that is equal to we have this 75 00:06:24,370 --> 00:06:27,400 little S.T. are with this. 76 00:06:27,400 --> 00:06:36,880 We would concatenate the upper little estie are dot the lowercase characters, all of this. 77 00:06:36,880 --> 00:06:46,180 Plus we would give a space slash D and new line also on all we would concatenate in letters and space. 78 00:06:47,200 --> 00:06:49,360 Then we would define a function. 79 00:06:50,370 --> 00:06:59,970 Now, that is our see law victory and that is Law Dictionary, and in this function, the first thing 80 00:06:59,970 --> 00:07:04,550 we would create is a dictionary file. 81 00:07:05,550 --> 00:07:09,990 And here we would use open and we would give that file, that is. 82 00:07:11,420 --> 00:07:18,240 Dictionary dot, the 60, the one which we have right now, created and saved in the same folder where 83 00:07:18,260 --> 00:07:19,970 we are able to see the current fight. 84 00:07:20,540 --> 00:07:29,450 So after giving this here, we will create the English votes SDR is equal to initially it is blank. 85 00:07:29,990 --> 00:07:46,210 We create for World One in our dictionary file, SDR dot read dot split using a slash and because on 86 00:07:46,220 --> 00:07:48,030 one line we are having one vote. 87 00:07:48,320 --> 00:07:51,040 So we are splitting it whenever we find a new line. 88 00:07:51,470 --> 00:08:02,240 And in that we are seeing English votes as are in the index of vote one, we are saving the value was 89 00:08:03,080 --> 00:08:04,160 none initially. 90 00:08:04,420 --> 00:08:16,820 OK, then we see a dictionary file is still not close and we are returning here and the value of English. 91 00:08:18,090 --> 00:08:26,600 Revolt's still and we end this function here and then we see the English votes. 92 00:08:26,950 --> 00:08:34,670 Our vote is equal to we are calling the law dictionary method that we have created. 93 00:08:34,920 --> 00:08:39,020 So that will get stored in a constant name, English word estopinal.