1 00:00:00,210 --> 00:00:06,480 Now, in this session, we could be looking at the simple substitution cipher now in the last session 2 00:00:06,480 --> 00:00:13,500 we have learned that the Afine Saiful has about a thousand possibilities, but that computers can still 3 00:00:13,500 --> 00:00:15,870 brute force through all of them easily. 4 00:00:16,350 --> 00:00:22,680 So we need a cipher that has so many possibilities that no computer can brute force through them all. 5 00:00:23,130 --> 00:00:30,060 So the simple substitution cipher is one such cipher that is effectively invulnerable to a brute force 6 00:00:30,060 --> 00:00:34,110 attack because it has enormous number of possible keys. 7 00:00:34,560 --> 00:00:40,710 Even if your computer could try a trillion keys every second, it would still take 12 million years 8 00:00:40,710 --> 00:00:42,150 for it to try every one. 9 00:00:42,690 --> 00:00:48,600 So in this particular session, we would write a program to implement a simple substitution cipher and 10 00:00:48,600 --> 00:00:52,410 learn some useful python functions and string methods as well. 11 00:00:53,040 --> 00:00:57,180 So topics covered in this particular session will be the smallest matter. 12 00:00:57,600 --> 00:01:04,350 Getting rid of the duplicate characters from a string of functions and using his opponent is lower string 13 00:01:04,350 --> 00:01:05,560 functions or methods. 14 00:01:06,090 --> 00:01:09,080 So moving on to how a simple substitution cipher. 15 00:01:09,960 --> 00:01:17,320 Now, to understand this, let us go to a blank Excel now to implement the simple substitution cipher. 16 00:01:17,610 --> 00:01:23,970 We basically choose a random letter to encrypt each letter of the alphabet and using each letter only 17 00:01:23,970 --> 00:01:24,360 once. 18 00:01:24,720 --> 00:01:31,350 Now the key for a simple substitution cipher is always a string of twenty six letters of the alphabet 19 00:01:31,350 --> 00:01:32,570 in any random order. 20 00:01:32,940 --> 00:01:40,400 And if you look at it, there are basically four zero three two nine one four six one one twenty six 21 00:01:40,400 --> 00:01:48,340 six zero five six thirty five five eight for so many number of different keys available. 22 00:01:48,840 --> 00:01:54,540 Now there are so many different possible key ordering for a simple substitution, and this is a lot 23 00:01:54,540 --> 00:01:55,100 more keys. 24 00:01:55,260 --> 00:02:00,390 So more importantly, this number is so large that it is impossible to brute forces. 25 00:02:00,870 --> 00:02:06,480 Now, let us try using a simple substitution cipher with paper and a pencil like we would be doing it 26 00:02:06,480 --> 00:02:08,310 on Excel, for example. 27 00:02:08,320 --> 00:02:14,730 They will encrypt the message said by hacking, for example. 28 00:02:15,240 --> 00:02:17,790 Now here we would be using certain keys. 29 00:02:18,000 --> 00:02:23,010 Now we would write down our alphabet and the corresponding keys under each alphabet. 30 00:02:23,280 --> 00:02:28,190 So say, for example, we would write down here all the alphabet, the capital alphabet. 31 00:02:28,500 --> 00:02:32,730 So A.B., let's take it from this. 32 00:02:33,030 --> 00:02:38,340 A, b, c, d, e, f, g. 33 00:02:39,960 --> 00:02:48,410 H i j k l m n o p q oreste. 34 00:02:50,430 --> 00:02:54,360 W, X, Y, Z and. 35 00:02:56,550 --> 00:02:58,660 Let's make it small. 36 00:02:59,010 --> 00:02:59,970 For example. 37 00:03:04,070 --> 00:03:06,260 For that, it is just viewed. 38 00:03:07,720 --> 00:03:10,770 So all together, we don't need to scroll. 39 00:03:16,030 --> 00:03:25,030 And below this, we would be writing down the keys and I'll say we would be using your keys as we G, 40 00:03:25,600 --> 00:03:50,440 that B, G and F to be L i d m x said w w then Q. You see why he h s o. 41 00:03:50,770 --> 00:03:53,820 So every character again used just once. 42 00:03:54,520 --> 00:04:02,080 So if you see hear this, every single character is having another substituted character for it, and 43 00:04:02,080 --> 00:04:04,310 these characters are also not repeating in it. 44 00:04:04,660 --> 00:04:10,630 So in that case, only if you see this same is substituted by those same characters. 45 00:04:10,630 --> 00:04:11,740 Viterbi same. 46 00:04:11,740 --> 00:04:13,350 But others are totally different now. 47 00:04:13,370 --> 00:04:18,440 This combination of random character generations could be a very large number. 48 00:04:18,820 --> 00:04:24,010 So in part, in this particular case, not to encrypt the message, we will find the plaintext from 49 00:04:24,010 --> 00:04:26,730 the top root and we substitute the letter in the bottom. 50 00:04:27,160 --> 00:04:33,520 So if we just write down it over here that we have that this post is B, so B, we'll take it. 51 00:04:34,820 --> 00:04:46,940 The Intrepid will be saved by then w then we have like so very having s the B is having C, H is having 52 00:04:46,940 --> 00:04:55,520 a substitution of E, always having substitution of B and end is having a substitution of X, then we 53 00:04:55,520 --> 00:04:56,570 are having hacking. 54 00:04:56,570 --> 00:05:00,770 So H is having a substitution of E A's having off. 55 00:05:00,770 --> 00:05:06,920 We then C is having a Z, he is having a substitution of pi. 56 00:05:07,460 --> 00:05:17,210 Similarly N is X and G is F, so this is what would be OK and cryptic text would look like, like. 57 00:05:18,050 --> 00:05:23,960 So not to decrypt the encrypted message you will find the letter in the cipher, text in the bottom 58 00:05:23,960 --> 00:05:27,100 row and you would replace it with the corresponding letter in the top. 59 00:05:27,650 --> 00:05:32,950 So like for example your W which will be replaced by B, so on and so forth. 60 00:05:33,200 --> 00:05:38,900 So unlike a Caesar cipher in which the bottom row shifts but remains in the alphabetical order in a 61 00:05:38,900 --> 00:05:42,590 simple substitution cipher, bottom row is completely scrambled. 62 00:05:43,010 --> 00:05:49,870 So this results in far more possible, which is a huge advantage of using a simple substitution cipher. 63 00:05:50,300 --> 00:05:58,580 And now the disadvantage is that the key is a twenty six characters long and more difficult to memorize. 64 00:05:58,730 --> 00:06:04,580 You may need to write down the key somewhere, but if you do so, make sure that no one is ever reset. 65 00:06:05,090 --> 00:06:08,520 OK, now let's come to a simple substitution cipher code. 66 00:06:08,980 --> 00:06:12,290 OK, we'll go back to let's close this. 67 00:06:13,820 --> 00:06:15,710 OK, now another potential. 68 00:06:15,980 --> 00:06:21,890 We would create a new file and we would enter the code in this file at the top and then save it and 69 00:06:21,890 --> 00:06:23,300 execute it again. 70 00:06:23,300 --> 00:06:27,770 We will place this in the same folder where we have the paperclip module.