Now coming to finding the Modula involved, now to calculate the Modula involved, to determine the
decryption key, you could take a brute force approach and stop testing the integer one and then two
and three and so on.
But this is the time consuming for large keys if you have some very light.
So fortunately, you can use the Euclid's extended algorithm to find the modular inverse of a number,
which is a pipe which in Python basically looks like we will use it by defining a particular method.
OK, just for your understanding, if we define here, say we find more inverse which stick to a common
aim as the parameters and here we check if gcd acoma am ok.
If that is not equal to one, then we are seeing Halyburton none and then we use he'll say you want
you to Yewtree as equal to one zero eight respectively.
Similarly say v1 v2 v three equal to zero one for example.
And we say Hyle V three is not equal to zero.
We are putting it in two is equal to say you three and we are saying we want we to be three.
You want you to use three is equal to say you one minus you multiply it by one.
Similarly next you two minus, you multiply it by two and next so you three minus skew multiplied by
V three and one comma with two comma V three.
OK, and then finally we say return.
You want Modula and OK.
Now in this basic example that we have done, you need to understand how the Euclid's extended algorithm
works.
OK, now as long as you have two arguments to posit to define more inverse function, which are relatively
bright, it will return the modular inverse of the given of particular parameter.
So succumbing to the integer division operation, we won't see if this is just for your understanding
corpus.
OK, now you may notice that the double slash operator is used in the if you just look at this, you
must have noticed here of you have made a mistake that the skill is equal to we have to do you three.
Now, that is double slash V three.
OK, now if you have noticed that we have used the double slash operator, OK, now we divide two numbers
and rounds down to the nearest integer if we want to see how this operator looks.
OK, if we go back to our interactive shell and if we say, for example, thirty one divided by seven,
we get some numbers in the numbers.
But if we say the decimal numbers, if we say double backslash seven, we get it rounded off to four
or we get to see then by five that already comes to two.
OK, so over here variable, you are getting the equation or whatever that expression is evaluating
the decimal point.
If we use a double backslash, OK, you are getting a whole number of it.
So a division expression that do not divide evenly.
The double slash operator is useful for getting the whole number part of the answer.
This is sometimes also called the ocean.
Now, while the percentage operator gets the remainder, an expression that uses double digit division
operator always evaluates to an end, not of look.
OK, so for example, if we said then divide by five point the same thing, if we say then divide by
five, we get only two two point zero.
So now let us write down a source code for a math.
We would be using a juked and the Finemore inverse method only when Mausi for programs later.
But over here we would put both of these functions into a module.
So as we have created this way, we have already defined the Finemore in.
The first thing we will try out over here is we will define the GCD pass A comma, B and as the parameter.
And here we would say while A is not equal to zero, we are seeing a comma, B is equal to B modulo
E and A, and then we use on the value of B that we end this function.
Then we have defined more involved which is taking again and amosite parameter.
And here we are checking if.
My aim is not equal to one then we are saying return not OK, otherwise we are calculating the extended
Euclidean algorithm and we are seeing here.
See you and you two.
You three is equal to one zero eight.
And we want to be three is equal to zero one.
And then we say height.
We three is not equal to zero.
We are saying give you three double more slash V three.
And now here we have uses integer division operator and then we have used this assignment operator.
We are going to use one model and now this program contains the GCD function described earlier and defined
more inverse function also, which implements your Euclid's extended algorithm now after importing this.
Now suppose we save this say are saving it in our intermediate level for long and we give it a name
C Cryptome at one be OK.
And now if you have to suppose, go to the interactive shell here and the first thing you'll see is
import C Cryptome up one dot or import Cryptome that one.
Also this import Krypto math one.
OK, and now if we see Krypto that one dot we use to find out some number, we get the values.
Similarly, let's use one more C Cryptome, that one or GCD some different number.
We still get it.
Or if we try to use Cryptome at one dot say find more inverse, forgive FF7 comma twenty six or if we
try Cryptome that one or find more in what we give the higher number.
OK, let's see
one find more inverse.
We give you say eight nine five three eight five one C twenty six.
Yeah.
You get the particular value.
OK, so in this way you can see you can call the function also and you find more inverse function to
find the jackdaw modular inverse for you will know this particular file we would be using in our next
session for implementing.
We are fine cyphers.