So now let us understand how many pages of fine cipher have now let us try to calculate the number of
possible keys.
The afine cipher has a fine ciphers key V1 is limited to the size of this.
Envisat with the length of your symbolistic is 66.
So at first glance, it seems like he even would be larger or as large as you want it to be, as long
as it's relatively plain to the simple set size.
Therefore, you might think that the afine cipher has an infinite number of keys and cannot be brute
force.
But this is not the case.
Recall how large keys in this season Saiful end up being the same as monarchies due to the wraparound
effect.
So with this implicit size of 66, the key sixty seven in the Caesar cipher would produce the same encrypted
text as given the afine.
Saiful also wrap around in this now because the key be one part of the afine cipher is Seimas.
You'll see the cipher.
Its range is limited from one to the size of this implicit not to determine whether the offensive A1
is also limited will write down a short program to encrypt the message using several different individuals
key even and see what is the ciphertext look like.
So we'll open a new file editor and into some code into it.
Save it with a particular name in the same folder as we had the a fine cipher program created and the
Cryptome at one fight.
So let us create your new file.
Now, in this, the first thing is we would import our.
A fine.
Saiful.
Demo and the diplomat won, and now here we will see the message a SDR is equal to will give you some
text.
See, this is as simple as possible, but not simpler, something like that.
And we would run for Loop Saiki even in the range we give you say two comma a T, we run.
This syquia still is equal to A1, multiplied by the length of now here we will use the afine Saiful
Demel got our Symbolistic plus one.
Then we check that if say Cryptome at one dot we call the GCD function because they're A1 and the length
of a fine.
So for the Modot Symbolistic that's equal to one.
Then we give print c p a1 comma the afine cipher demo Daudt.
We call here the encrypt message still and parse the SDR messages to.
So we will see if this program in the same location, let us give your CI a. find the demo bought by.
And if after saving this, let us execute this.
So cute how many kids it is using any random number of kids now in this particular program that we have
written, we are importing the afine for demo for the encrypted message function and the crypto math.
One module for its function will always encrypt the string stored in the message is still variable.
So the for loop remains in the range between two to eight because in this case, zero and one are not
allowed or not allowed as a valid GUI Kansi.
So an integer as explained earlier.
So on each iteration of the loop, we calculate the key from the current one and always uses one for
cabi one, which is why one is added at the end of the particular session over here after default.
Now keep in mind that A1 must be relatively primes with a simple set size to be valid.
So key one is relatively private with the size of the city of the key and the symbol size is equal to
one.
So if the core of the key and the symbol sets, it is not equal to one, the if condition on this particular
line will fail or will skip the call to encrypt message.
So in short, this program prints the same message encrypted with several different integers for which
the output we have seen this.
So look carefully at the output.
You will notice that the ciphertext, let's say for P1 four five let's see over here is the same as
the ciphertext for let's say check it over here.
See this one similar to this.
Seventy one, OK, in fact ciphertext from seven and seventy three are also C if you look at this see
seventy three and see this one.
This also all same.
Right.
And the ciphertext for totin.
If you look at this one and you'll see seventy nine, this one is also C so notice that subtracting
five from seventy one thousand sixty six size of of a symbol, this is like one of seventy one does
the same thing as a one of five.
The encrypted output repeat itself or wrap around every six to six keys.
So as you can see the a fine cipher has a same wraparound effect for even as it does for every one.
So in some key, Ivana's also limited to the symbols.
Now when you multiply six to six possible keys, A1 keys by six two six possible keys V1, the result
is four, three, five, six possible combinations.
Now, when you subtract the individuals that can't be used for a because they are not relatively Prineville
66, then the total number of possible combinations of finci four drops to one three to zero.
So now we would come to understand what is writing the encryption function, which we have written in
our fine cipher fight.
So let us close this key demo now as we have understood this and let's go back to this for now.
Here will come to the encrypt messages.
So now here, this is basically used to encrypt the given message.
Take the parameter.
Now we need to get the integer values for key A1 and we run from the get method that we have defined
by passing it on the particular key still.
So next we check whether these guys are valid by passing them to the check estimator or what you know,
if your check function doesn't cause the program to exit, the keys are valid and the rest of the code
in the encrypt message function will execute.
So here we are.
Having the ciphertext is still a variable that starts as a blank string, but will eventually hold the
encrypted string, the for loop that begins iterate through each of the characters in your messages
and then add the encrypted character to your ciphertext Istria.