1 00:00:00,240 --> 00:00:06,900 So now let us understand how many pages of fine cipher have now let us try to calculate the number of 2 00:00:06,900 --> 00:00:07,830 possible keys. 3 00:00:08,130 --> 00:00:14,160 The afine cipher has a fine ciphers key V1 is limited to the size of this. 4 00:00:14,170 --> 00:00:18,550 Envisat with the length of your symbolistic is 66. 5 00:00:18,990 --> 00:00:27,150 So at first glance, it seems like he even would be larger or as large as you want it to be, as long 6 00:00:27,150 --> 00:00:30,590 as it's relatively plain to the simple set size. 7 00:00:30,900 --> 00:00:37,200 Therefore, you might think that the afine cipher has an infinite number of keys and cannot be brute 8 00:00:37,200 --> 00:00:37,610 force. 9 00:00:37,860 --> 00:00:39,180 But this is not the case. 10 00:00:39,240 --> 00:00:47,280 Recall how large keys in this season Saiful end up being the same as monarchies due to the wraparound 11 00:00:47,280 --> 00:00:47,670 effect. 12 00:00:48,090 --> 00:00:55,470 So with this implicit size of 66, the key sixty seven in the Caesar cipher would produce the same encrypted 13 00:00:55,470 --> 00:00:58,110 text as given the afine. 14 00:00:58,110 --> 00:01:05,250 Saiful also wrap around in this now because the key be one part of the afine cipher is Seimas. 15 00:01:05,250 --> 00:01:06,240 You'll see the cipher. 16 00:01:06,450 --> 00:01:14,060 Its range is limited from one to the size of this implicit not to determine whether the offensive A1 17 00:01:14,100 --> 00:01:20,210 is also limited will write down a short program to encrypt the message using several different individuals 18 00:01:20,430 --> 00:01:23,970 key even and see what is the ciphertext look like. 19 00:01:24,330 --> 00:01:27,770 So we'll open a new file editor and into some code into it. 20 00:01:27,780 --> 00:01:34,290 Save it with a particular name in the same folder as we had the a fine cipher program created and the 21 00:01:34,290 --> 00:01:35,530 Cryptome at one fight. 22 00:01:36,030 --> 00:01:38,820 So let us create your new file. 23 00:01:39,240 --> 00:01:42,480 Now, in this, the first thing is we would import our. 24 00:01:43,470 --> 00:01:44,130 A fine. 25 00:01:45,140 --> 00:01:45,890 Saiful. 26 00:01:47,310 --> 00:01:57,780 Demo and the diplomat won, and now here we will see the message a SDR is equal to will give you some 27 00:01:57,780 --> 00:01:58,260 text. 28 00:01:58,560 --> 00:02:11,550 See, this is as simple as possible, but not simpler, something like that. 29 00:02:12,270 --> 00:02:23,280 And we would run for Loop Saiki even in the range we give you say two comma a T, we run. 30 00:02:23,280 --> 00:02:34,800 This syquia still is equal to A1, multiplied by the length of now here we will use the afine Saiful 31 00:02:35,130 --> 00:02:41,220 Demel got our Symbolistic plus one. 32 00:02:41,610 --> 00:02:55,470 Then we check that if say Cryptome at one dot we call the GCD function because they're A1 and the length 33 00:02:55,470 --> 00:02:57,150 of a fine. 34 00:02:58,260 --> 00:03:04,530 So for the Modot Symbolistic that's equal to one. 35 00:03:05,250 --> 00:03:15,640 Then we give print c p a1 comma the afine cipher demo Daudt. 36 00:03:15,660 --> 00:03:26,520 We call here the encrypt message still and parse the SDR messages to. 37 00:03:29,100 --> 00:03:41,580 So we will see if this program in the same location, let us give your CI a. find the demo bought by. 38 00:03:43,400 --> 00:03:48,590 And if after saving this, let us execute this. 39 00:03:50,020 --> 00:03:57,220 So cute how many kids it is using any random number of kids now in this particular program that we have 40 00:03:57,220 --> 00:04:03,960 written, we are importing the afine for demo for the encrypted message function and the crypto math. 41 00:04:03,970 --> 00:04:10,850 One module for its function will always encrypt the string stored in the message is still variable. 42 00:04:11,080 --> 00:04:17,110 So the for loop remains in the range between two to eight because in this case, zero and one are not 43 00:04:17,110 --> 00:04:19,650 allowed or not allowed as a valid GUI Kansi. 44 00:04:19,960 --> 00:04:22,140 So an integer as explained earlier. 45 00:04:22,660 --> 00:04:29,410 So on each iteration of the loop, we calculate the key from the current one and always uses one for 46 00:04:29,410 --> 00:04:36,890 cabi one, which is why one is added at the end of the particular session over here after default. 47 00:04:37,660 --> 00:04:42,910 Now keep in mind that A1 must be relatively primes with a simple set size to be valid. 48 00:04:43,180 --> 00:04:49,600 So key one is relatively private with the size of the city of the key and the symbol size is equal to 49 00:04:49,600 --> 00:04:49,850 one. 50 00:04:50,320 --> 00:04:56,230 So if the core of the key and the symbol sets, it is not equal to one, the if condition on this particular 51 00:04:56,230 --> 00:05:00,850 line will fail or will skip the call to encrypt message. 52 00:05:01,150 --> 00:05:07,630 So in short, this program prints the same message encrypted with several different integers for which 53 00:05:07,630 --> 00:05:09,240 the output we have seen this. 54 00:05:09,670 --> 00:05:11,990 So look carefully at the output. 55 00:05:12,010 --> 00:05:19,030 You will notice that the ciphertext, let's say for P1 four five let's see over here is the same as 56 00:05:19,030 --> 00:05:22,800 the ciphertext for let's say check it over here. 57 00:05:23,500 --> 00:05:25,750 See this one similar to this. 58 00:05:25,750 --> 00:05:32,910 Seventy one, OK, in fact ciphertext from seven and seventy three are also C if you look at this see 59 00:05:32,920 --> 00:05:35,220 seventy three and see this one. 60 00:05:35,890 --> 00:05:36,880 This also all same. 61 00:05:37,660 --> 00:05:38,080 Right. 62 00:05:38,410 --> 00:05:40,510 And the ciphertext for totin. 63 00:05:40,510 --> 00:05:49,210 If you look at this one and you'll see seventy nine, this one is also C so notice that subtracting 64 00:05:49,210 --> 00:05:56,470 five from seventy one thousand sixty six size of of a symbol, this is like one of seventy one does 65 00:05:56,470 --> 00:05:58,870 the same thing as a one of five. 66 00:05:59,350 --> 00:06:04,050 The encrypted output repeat itself or wrap around every six to six keys. 67 00:06:04,300 --> 00:06:10,740 So as you can see the a fine cipher has a same wraparound effect for even as it does for every one. 68 00:06:11,140 --> 00:06:14,380 So in some key, Ivana's also limited to the symbols. 69 00:06:15,160 --> 00:06:22,570 Now when you multiply six to six possible keys, A1 keys by six two six possible keys V1, the result 70 00:06:22,570 --> 00:06:25,070 is four, three, five, six possible combinations. 71 00:06:25,570 --> 00:06:32,080 Now, when you subtract the individuals that can't be used for a because they are not relatively Prineville 72 00:06:32,080 --> 00:06:38,140 66, then the total number of possible combinations of finci four drops to one three to zero. 73 00:06:38,650 --> 00:06:44,830 So now we would come to understand what is writing the encryption function, which we have written in 74 00:06:44,830 --> 00:06:46,250 our fine cipher fight. 75 00:06:46,720 --> 00:06:54,400 So let us close this key demo now as we have understood this and let's go back to this for now. 76 00:06:54,400 --> 00:06:56,680 Here will come to the encrypt messages. 77 00:06:57,520 --> 00:07:01,750 So now here, this is basically used to encrypt the given message. 78 00:07:01,900 --> 00:07:02,990 Take the parameter. 79 00:07:03,340 --> 00:07:10,930 Now we need to get the integer values for key A1 and we run from the get method that we have defined 80 00:07:11,230 --> 00:07:14,110 by passing it on the particular key still. 81 00:07:14,380 --> 00:07:20,590 So next we check whether these guys are valid by passing them to the check estimator or what you know, 82 00:07:20,860 --> 00:07:27,850 if your check function doesn't cause the program to exit, the keys are valid and the rest of the code 83 00:07:27,850 --> 00:07:30,610 in the encrypt message function will execute. 84 00:07:31,270 --> 00:07:32,260 So here we are. 85 00:07:32,260 --> 00:07:38,830 Having the ciphertext is still a variable that starts as a blank string, but will eventually hold the 86 00:07:38,830 --> 00:07:45,810 encrypted string, the for loop that begins iterate through each of the characters in your messages 87 00:07:46,180 --> 00:07:51,300 and then add the encrypted character to your ciphertext Istria.