1 00:00:00,310 --> 00:00:06,670 Now, in this particular session, we would be learning about the multiplicative cipher and the offensive. 2 00:00:07,110 --> 00:00:13,770 Now the multiplicative cipher is similar to you'll see the cipher, but encrypt using the multiplications 3 00:00:13,770 --> 00:00:14,790 rather than edition. 4 00:00:15,180 --> 00:00:21,540 And the afine cipher combines the multiplicative cipher and the Caesar Saiful, resulting in a stronger 5 00:00:21,540 --> 00:00:23,490 and a more reliable encryption. 6 00:00:23,670 --> 00:00:29,910 But first, you should learn about the modular arithmetic and the greatest common divisors to mathematical 7 00:00:29,910 --> 00:00:34,170 concepts that are required to understand and implement the afine cipher. 8 00:00:34,590 --> 00:00:41,010 So using these concepts, we will create a module to handle a wraparound and find the valid keys for 9 00:00:41,010 --> 00:00:41,910 the afine safe. 10 00:00:42,150 --> 00:00:47,130 And we would be using this module when we create a program for a fine cipher in the next session. 11 00:00:47,310 --> 00:00:52,890 OK, so in this particular session we would be covering modular arithmetic, the modulo operator, the 12 00:00:52,890 --> 00:01:00,060 greatest common deviser multiple assignment using the aliased algorithm for finding the GCT. 13 00:01:00,060 --> 00:01:03,500 That is the greatest common deviser, the multiplicative undefined. 14 00:01:04,350 --> 00:01:10,470 And we will extend the algorithm for finding the modular involves, starting with the modular arithmetic. 15 00:01:10,860 --> 00:01:17,880 Now the modular arithmetic or the clock arithmetic refers to math in which numbers wrap around when 16 00:01:17,880 --> 00:01:19,410 they reach a particular value. 17 00:01:19,800 --> 00:01:24,360 We will use modular arithmetic to handle wraparound in the afine safely. 18 00:01:24,810 --> 00:01:31,950 Now let's see how we would basically imagine a clock would just on our hand and Otwell replaced with 19 00:01:31,950 --> 00:01:32,340 a zero. 20 00:01:32,790 --> 00:01:36,300 If program was designed below, the first one would begin at zero. 21 00:01:36,690 --> 00:01:41,310 So if the current time is at three o'clock, what time it will be in five? 22 00:01:41,940 --> 00:01:43,500 That is easy enough to figure out. 23 00:01:43,500 --> 00:01:44,550 That is three plus five. 24 00:01:44,550 --> 00:01:45,180 That is eight. 25 00:01:45,540 --> 00:01:47,030 It will be eight o'clock and five. 26 00:01:47,070 --> 00:01:52,650 I think of an upper hand starting at three and then moving five hours clockwise. 27 00:01:53,040 --> 00:01:56,520 If the current time is 10:00, what time it would be in five. 28 00:01:56,520 --> 00:01:58,260 Also adding five plus 10. 29 00:01:58,260 --> 00:01:59,090 That is 15. 30 00:01:59,490 --> 00:02:02,320 But 15 o'clock doesn't make sense for clock. 31 00:02:02,370 --> 00:02:03,450 That shows only 12. 32 00:02:04,140 --> 00:02:09,050 So to find out for time, it will be you have to subtract 15 minus 12. 33 00:02:09,060 --> 00:02:09,770 That is three. 34 00:02:10,020 --> 00:02:11,580 So it will be three o'clock. 35 00:02:11,820 --> 00:02:17,900 So normally you would distinguish between three a.m. and three p.m. but that doesn't matter in a modular 36 00:02:17,910 --> 00:02:19,430 and not double. 37 00:02:19,440 --> 00:02:22,500 Check this math by moving the other hand clockwise. 38 00:02:22,500 --> 00:02:24,080 Fiverr will starting something. 39 00:02:24,450 --> 00:02:26,310 It does indeed land on three. 40 00:02:26,700 --> 00:02:30,600 If the current time timewasting, what time it will be in two hundred. 41 00:02:31,230 --> 00:02:37,590 So adding two hundred plus ten is stupid and two then is certainly larger than 12 because one full rotation 42 00:02:37,590 --> 00:02:40,350 brings the hour hand back to its original position. 43 00:02:40,620 --> 00:02:46,910 Now we can solve this problem by subtracting 12, which is one rotation until the result is less adding 44 00:02:47,100 --> 00:02:47,420 to it. 45 00:02:47,580 --> 00:02:52,560 So subtracting to by 12 is 198 again, 798 still. 46 00:02:52,890 --> 00:02:57,090 So again, you say continue to subtract 12 until the difference is less, then do it. 47 00:02:57,120 --> 00:02:59,940 So in this case, the final answer would come to six. 48 00:03:00,330 --> 00:03:05,100 So if the current time is ten o'clock, the time two hundred hours later would be six o'clock. 49 00:03:05,160 --> 00:03:11,100 So if you want to double check the ten o'clock plus two hundred hours maddigan repeatedly move the round 50 00:03:11,100 --> 00:03:16,720 and round the clock face when you move the four hand for both of us, it should have. 51 00:03:17,460 --> 00:03:23,730 However, it is easier to have the computer do this modular arithmetic for us with the modulo operator. 52 00:03:24,060 --> 00:03:30,540 So coming to the modulo operator you can use the modulo operator abbreviated as more to write down the 53 00:03:30,540 --> 00:03:31,710 modular expressions. 54 00:03:31,710 --> 00:03:37,590 Now in Python, the more operator is the person the site you can think of a more operator as a kind 55 00:03:37,590 --> 00:03:44,810 of division reminder operator for example, if we see twenty one divided by five comes to four with 56 00:03:44,820 --> 00:03:49,520 the remainder of one and if we say twenty one modulo five, it comes to one. 57 00:03:49,890 --> 00:03:54,630 So similarly, if you see 15 modulo 12, it is equal to three. 58 00:03:54,630 --> 00:04:01,980 Just as 15 o'clock would be three o'clock and falling into the interactive shell to see how the operator 59 00:04:01,980 --> 00:04:03,000 is coming to us. 60 00:04:03,690 --> 00:04:12,060 If we go here we type say twenty one, say more below five, you get the value one if we see and plus 61 00:04:12,540 --> 00:04:16,020 two hundred modulo two if we get sick. 62 00:04:16,410 --> 00:04:19,350 If we see it then modulated that is zero. 63 00:04:19,680 --> 00:04:26,910 If we say 20 more below 10 that's also coming to zero, not just as ten o'clock plus two hundred obviously 64 00:04:26,910 --> 00:04:30,120 wrap 6:00 on the clock with twelve hours. 65 00:04:30,360 --> 00:04:34,230 That is ten plus two hundred divided by modulo twelve will evaluate. 66 00:04:35,040 --> 00:04:41,880 Notice that numbers are divided evenly with more to zero suggesting or ten or twenty modulated. 67 00:04:42,510 --> 00:04:46,550 Later we will use the operator to handle wraparound in the offensive. 68 00:04:47,010 --> 00:04:53,410 It's also used in the algorithm that we will use to find the greatest common deviser of Poonam now, 69 00:04:53,520 --> 00:04:57,050 which is enable us to find the valid use for the offensive. 70 00:04:57,600 --> 00:04:59,920 So moving to finding the fact those two can. 71 00:05:00,310 --> 00:05:05,740 The greatest common device, no fact, those are the numbers that are multiply to produce a particular 72 00:05:05,740 --> 00:05:11,950 number considered or foreign to six, that's 20 for now in this equation, four and six are the factors 73 00:05:11,950 --> 00:05:17,620 of twenty four, because a number of factors can also be used to divide that number without leaving 74 00:05:17,620 --> 00:05:18,090 any mind. 75 00:05:18,250 --> 00:05:20,400 So factors are also called devices. 76 00:05:20,950 --> 00:05:27,220 So number twenty four also has some other factor that is the age into comes through for 12 to two also 77 00:05:27,220 --> 00:05:30,330 comes to twenty four, twenty four and one also is twenty four. 78 00:05:30,580 --> 00:05:36,490 So the fact those are for reform would be say one, two, three, four, six, eight, 12 and 20 for 79 00:05:36,490 --> 00:05:36,980 itself. 80 00:05:37,450 --> 00:05:44,560 Similarly, if we look at the factors of 30, we may have one in to 32 into 15, three to 10 or say 81 00:05:44,560 --> 00:05:45,550 five to six. 82 00:05:45,940 --> 00:05:50,620 The factors of 30 would be say one, two, three, five, 10, 15 and 30. 83 00:05:51,460 --> 00:05:55,390 So note that any number will have one on itself. 84 00:05:55,390 --> 00:05:58,690 And it's a factor because one time the number is equal to that number. 85 00:05:59,080 --> 00:06:04,090 Notice, too, that the list of factors of twenty four and thirty one, two, three, six income. 86 00:06:04,450 --> 00:06:09,970 So the greatest of these common factors is six or six is the greatest common factor, more commonly 87 00:06:09,970 --> 00:06:12,970 known as the D.C. the of twenty four. 88 00:06:12,970 --> 00:06:20,590 And now it is easier to find the good of two numbers by visualizing the effect we will visualize fractals 89 00:06:20,590 --> 00:06:24,590 and the GCD is using some some manual approach also. 90 00:06:24,640 --> 00:06:24,870 OK.