Now, let's just have a look here.
If we import the random, then we see random vehicles here, we see the values 42 we give your numbers
to are as blank and we a before I even in the range see we are generating.
Say twenty five values, for example.
And in this values we are giving in, Ameristar got up and the values generated from random violent
one comma twenty five after which we give your command for no asdf, we get those twenty five numbers
generated again second time.
If we see random thought then using the same set value here as above that is 42.
And again we are saying no, Oresteia equals to blank.
Then we are windrunner for Lopsang even in the range say twenty five, open the loop and say here no
estie are not up and the random dot grand and one comma twenty five.
And then again we give print four numbers.
So again if you just compare the values, all the values are exactly the same as we have in the first
one.
So here we have generated the twenty five numbers twice using the same set value, plus we have imported
it and then said this to forty two.
Then we have set up a list called has no idea where we are storing all of our generated numbers.
We use a for loop for this to generate 20 numbers and we are appending each one to the numbers which
we print so that we see the every number that was generated.
Now when the seed of the Python pseudo random number generator is set to forty to the first random number
between one and twenty five will always be twenty one.
The second number will always be safe for it or no will always be C one.
And the same set of pseudo random numbers is written from random doctorand and as you can see by comparing
the numbers, Asgeir both the predicament that we have executed.
So the random numbers will become important for cyphers in the later sections because they are used
not only for testing ciphers, but also for encrypting and decrypting in a more complex, lifeless.
So random numbers are so important that one common security flaw in encryption soffit is using a predictable
random numbers.
If random numbers in your programs can be predicted, then a cryptanalysis can use this information
to break your cipher.
So selecting the encryption key is a truly random manner is necessary for the security of a cipher.
But for other uses such as this code that we have used, pseudo random numbers are fine.
It will also see the use of pseudo random numbers to generate test strings for a test or programs.
Now you can generate truly random numbers with Python by using the random dot system random, not random
functions.
We will learn this later in the particular session.
So now we'll move on to creating a random string.
Now that you have learned how to use your random Gaudron in Meterology function and random seed function
to create your random numbers.
Now let us return to the source code that we have used.
So let's go to over the 14. Beevor code and now see what completely automated code we have written for
encryption and decryption programs.
Now, for doing this, we will have to take a string of characters to use in the message.
String message is still duplicate it a random number of times and stored that as a string.
And then we will take the string of the duplicated characters and scramble them to make them more random.
Will also generate a new random string for each test so we can try many different combinations, all
the combinations.
So first of all, let us set up the main function, which contains the code that is the cipher program,
and it starts by setting the seed of the pseudo random string.
So inside the main, we first of all set random dot seed in bracket forty two.
So setting the random seed by calling random dot seed is useful for a test program because you want
predictable numbers.
So the same pseudo random message and the key are chosen each time the program is run.
So as a result, if you notice one message fails to encrypt decrypt properly, you will be able to reproduce
this feeling the test cases.
Next, what will have to do is duplicate a string using a for loop.
So duplicating a string or random number of times.
We are using here a loop which will run for 20 test and to generate our random messages.
So we run a loop thing for AI in the range of 20.
We generate.
Random values over your random messages, so each time the for loop iterates, the program will create
and test a new message.
We want this program to run multiple test because the more test we try, the more certain will be that
program or that program looks so later in the particular line.
We have the testing code that creates a message of random length and it takes a string of uppercase
characters and uses the front end method over here.
So after this, we're multiplying it by random, doctorand and giving them the value or giving the string
replication to duplicate the string or random number of times between four and 40.
That's the range that we have given.
And then it will store the new string in the same message as the variable.
So if we leave the message as string as it is now, it will always be just the alphabet.
String repeated a random number of times because we want to test different combinations of characters
or letters.
We will need to take things a step further and scramble the characters in the message to do that.
Let us first learn a bit more about what our list.