Now, in this particular session, we would be learning about the multiplicative cipher and the offensive.
Now the multiplicative cipher is similar to you'll see the cipher, but encrypt using the multiplications
rather than edition.
And the afine cipher combines the multiplicative cipher and the Caesar Saiful, resulting in a stronger
and a more reliable encryption.
But first, you should learn about the modular arithmetic and the greatest common divisors to mathematical
concepts that are required to understand and implement the afine cipher.
So using these concepts, we will create a module to handle a wraparound and find the valid keys for
the afine safe.
And we would be using this module when we create a program for a fine cipher in the next session.
OK, so in this particular session we would be covering modular arithmetic, the modulo operator, the
greatest common deviser multiple assignment using the aliased algorithm for finding the GCT.
That is the greatest common deviser, the multiplicative undefined.
And we will extend the algorithm for finding the modular involves, starting with the modular arithmetic.
Now the modular arithmetic or the clock arithmetic refers to math in which numbers wrap around when
they reach a particular value.
We will use modular arithmetic to handle wraparound in the afine safely.
Now let's see how we would basically imagine a clock would just on our hand and Otwell replaced with
a zero.
If program was designed below, the first one would begin at zero.
So if the current time is at three o'clock, what time it will be in five?
That is easy enough to figure out.
That is three plus five.
That is eight.
It will be eight o'clock and five.
I think of an upper hand starting at three and then moving five hours clockwise.
If the current time is 10:00, what time it would be in five.
Also adding five plus 10.
That is 15.
But 15 o'clock doesn't make sense for clock.
That shows only 12.
So to find out for time, it will be you have to subtract 15 minus 12.
That is three.
So it will be three o'clock.
So normally you would distinguish between three a.m. and three p.m. but that doesn't matter in a modular
and not double.
Check this math by moving the other hand clockwise.
Fiverr will starting something.
It does indeed land on three.
If the current time timewasting, what time it will be in two hundred.
So adding two hundred plus ten is stupid and two then is certainly larger than 12 because one full rotation
brings the hour hand back to its original position.
Now we can solve this problem by subtracting 12, which is one rotation until the result is less adding
to it.
So subtracting to by 12 is 198 again, 798 still.
So again, you say continue to subtract 12 until the difference is less, then do it.
So in this case, the final answer would come to six.
So if the current time is ten o'clock, the time two hundred hours later would be six o'clock.
So if you want to double check the ten o'clock plus two hundred hours maddigan repeatedly move the round
and round the clock face when you move the four hand for both of us, it should have.
However, it is easier to have the computer do this modular arithmetic for us with the modulo operator.
So coming to the modulo operator you can use the modulo operator abbreviated as more to write down the
modular expressions.
Now in Python, the more operator is the person the site you can think of a more operator as a kind
of division reminder operator for example, if we see twenty one divided by five comes to four with
the remainder of one and if we say twenty one modulo five, it comes to one.
So similarly, if you see 15 modulo 12, it is equal to three.
Just as 15 o'clock would be three o'clock and falling into the interactive shell to see how the operator
is coming to us.
If we go here we type say twenty one, say more below five, you get the value one if we see and plus
two hundred modulo two if we get sick.
If we see it then modulated that is zero.
If we say 20 more below 10 that's also coming to zero, not just as ten o'clock plus two hundred obviously
wrap 6:00 on the clock with twelve hours.
That is ten plus two hundred divided by modulo twelve will evaluate.
Notice that numbers are divided evenly with more to zero suggesting or ten or twenty modulated.
Later we will use the operator to handle wraparound in the offensive.
It's also used in the algorithm that we will use to find the greatest common deviser of Poonam now,
which is enable us to find the valid use for the offensive.
So moving to finding the fact those two can.
The greatest common device, no fact, those are the numbers that are multiply to produce a particular
number considered or foreign to six, that's 20 for now in this equation, four and six are the factors
of twenty four, because a number of factors can also be used to divide that number without leaving
any mind.
So factors are also called devices.
So number twenty four also has some other factor that is the age into comes through for 12 to two also
comes to twenty four, twenty four and one also is twenty four.
So the fact those are for reform would be say one, two, three, four, six, eight, 12 and 20 for
itself.
Similarly, if we look at the factors of 30, we may have one in to 32 into 15, three to 10 or say
five to six.
The factors of 30 would be say one, two, three, five, 10, 15 and 30.
So note that any number will have one on itself.
And it's a factor because one time the number is equal to that number.
Notice, too, that the list of factors of twenty four and thirty one, two, three, six income.
So the greatest of these common factors is six or six is the greatest common factor, more commonly
known as the D.C. the of twenty four.
And now it is easier to find the good of two numbers by visualizing the effect we will visualize fractals
and the GCD is using some some manual approach also.
OK.