1 00:00:00,450 --> 00:00:02,370 Now, let's just have a look here. 2 00:00:02,520 --> 00:00:12,570 If we import the random, then we see random vehicles here, we see the values 42 we give your numbers 3 00:00:12,580 --> 00:00:19,860 to are as blank and we a before I even in the range see we are generating. 4 00:00:20,870 --> 00:00:22,860 Say twenty five values, for example. 5 00:00:23,270 --> 00:00:31,960 And in this values we are giving in, Ameristar got up and the values generated from random violent 6 00:00:32,450 --> 00:00:42,200 one comma twenty five after which we give your command for no asdf, we get those twenty five numbers 7 00:00:42,200 --> 00:00:44,690 generated again second time. 8 00:00:44,690 --> 00:00:50,790 If we see random thought then using the same set value here as above that is 42. 9 00:00:51,170 --> 00:00:55,010 And again we are saying no, Oresteia equals to blank. 10 00:00:55,490 --> 00:01:03,740 Then we are windrunner for Lopsang even in the range say twenty five, open the loop and say here no 11 00:01:03,750 --> 00:01:10,840 estie are not up and the random dot grand and one comma twenty five. 12 00:01:11,390 --> 00:01:14,740 And then again we give print four numbers. 13 00:01:15,710 --> 00:01:22,310 So again if you just compare the values, all the values are exactly the same as we have in the first 14 00:01:22,310 --> 00:01:22,500 one. 15 00:01:22,790 --> 00:01:29,840 So here we have generated the twenty five numbers twice using the same set value, plus we have imported 16 00:01:29,850 --> 00:01:31,630 it and then said this to forty two. 17 00:01:31,970 --> 00:01:38,090 Then we have set up a list called has no idea where we are storing all of our generated numbers. 18 00:01:38,330 --> 00:01:47,570 We use a for loop for this to generate 20 numbers and we are appending each one to the numbers which 19 00:01:47,570 --> 00:01:51,480 we print so that we see the every number that was generated. 20 00:01:51,920 --> 00:01:58,910 Now when the seed of the Python pseudo random number generator is set to forty to the first random number 21 00:01:58,910 --> 00:02:02,660 between one and twenty five will always be twenty one. 22 00:02:02,990 --> 00:02:08,360 The second number will always be safe for it or no will always be C one. 23 00:02:08,960 --> 00:02:15,860 And the same set of pseudo random numbers is written from random doctorand and as you can see by comparing 24 00:02:15,860 --> 00:02:20,790 the numbers, Asgeir both the predicament that we have executed. 25 00:02:21,230 --> 00:02:27,530 So the random numbers will become important for cyphers in the later sections because they are used 26 00:02:27,530 --> 00:02:34,910 not only for testing ciphers, but also for encrypting and decrypting in a more complex, lifeless. 27 00:02:35,270 --> 00:02:43,580 So random numbers are so important that one common security flaw in encryption soffit is using a predictable 28 00:02:43,580 --> 00:02:44,510 random numbers. 29 00:02:44,850 --> 00:02:51,320 If random numbers in your programs can be predicted, then a cryptanalysis can use this information 30 00:02:51,320 --> 00:02:52,650 to break your cipher. 31 00:02:53,090 --> 00:02:59,720 So selecting the encryption key is a truly random manner is necessary for the security of a cipher. 32 00:02:59,990 --> 00:03:05,140 But for other uses such as this code that we have used, pseudo random numbers are fine. 33 00:03:05,780 --> 00:03:12,720 It will also see the use of pseudo random numbers to generate test strings for a test or programs. 34 00:03:13,280 --> 00:03:21,970 Now you can generate truly random numbers with Python by using the random dot system random, not random 35 00:03:22,040 --> 00:03:22,630 functions. 36 00:03:23,270 --> 00:03:26,220 We will learn this later in the particular session. 37 00:03:26,660 --> 00:03:29,510 So now we'll move on to creating a random string. 38 00:03:29,900 --> 00:03:36,590 Now that you have learned how to use your random Gaudron in Meterology function and random seed function 39 00:03:36,830 --> 00:03:38,510 to create your random numbers. 40 00:03:38,750 --> 00:03:41,780 Now let us return to the source code that we have used. 41 00:03:41,990 --> 00:03:50,870 So let's go to over the 14. Beevor code and now see what completely automated code we have written for 42 00:03:50,870 --> 00:03:52,640 encryption and decryption programs. 43 00:03:53,240 --> 00:03:59,060 Now, for doing this, we will have to take a string of characters to use in the message. 44 00:03:59,060 --> 00:04:05,450 String message is still duplicate it a random number of times and stored that as a string. 45 00:04:05,780 --> 00:04:11,870 And then we will take the string of the duplicated characters and scramble them to make them more random. 46 00:04:12,470 --> 00:04:19,510 Will also generate a new random string for each test so we can try many different combinations, all 47 00:04:20,120 --> 00:04:21,030 the combinations. 48 00:04:21,290 --> 00:04:28,340 So first of all, let us set up the main function, which contains the code that is the cipher program, 49 00:04:28,580 --> 00:04:31,820 and it starts by setting the seed of the pseudo random string. 50 00:04:32,300 --> 00:04:37,870 So inside the main, we first of all set random dot seed in bracket forty two. 51 00:04:38,360 --> 00:04:44,660 So setting the random seed by calling random dot seed is useful for a test program because you want 52 00:04:44,840 --> 00:04:46,180 predictable numbers. 53 00:04:46,310 --> 00:04:51,960 So the same pseudo random message and the key are chosen each time the program is run. 54 00:04:52,370 --> 00:04:58,730 So as a result, if you notice one message fails to encrypt decrypt properly, you will be able to reproduce 55 00:04:58,730 --> 00:05:01,030 this feeling the test cases. 56 00:05:01,700 --> 00:05:06,200 Next, what will have to do is duplicate a string using a for loop. 57 00:05:06,410 --> 00:05:09,320 So duplicating a string or random number of times. 58 00:05:09,560 --> 00:05:15,710 We are using here a loop which will run for 20 test and to generate our random messages. 59 00:05:15,920 --> 00:05:18,960 So we run a loop thing for AI in the range of 20. 60 00:05:19,640 --> 00:05:20,270 We generate. 61 00:05:20,940 --> 00:05:28,080 Random values over your random messages, so each time the for loop iterates, the program will create 62 00:05:28,080 --> 00:05:29,490 and test a new message. 63 00:05:29,790 --> 00:05:37,410 We want this program to run multiple test because the more test we try, the more certain will be that 64 00:05:37,410 --> 00:05:41,740 program or that program looks so later in the particular line. 65 00:05:42,000 --> 00:05:48,720 We have the testing code that creates a message of random length and it takes a string of uppercase 66 00:05:48,720 --> 00:05:52,560 characters and uses the front end method over here. 67 00:05:53,010 --> 00:06:00,030 So after this, we're multiplying it by random, doctorand and giving them the value or giving the string 68 00:06:00,030 --> 00:06:05,380 replication to duplicate the string or random number of times between four and 40. 69 00:06:05,820 --> 00:06:07,530 That's the range that we have given. 70 00:06:07,710 --> 00:06:12,180 And then it will store the new string in the same message as the variable. 71 00:06:12,540 --> 00:06:18,810 So if we leave the message as string as it is now, it will always be just the alphabet. 72 00:06:18,810 --> 00:06:25,230 String repeated a random number of times because we want to test different combinations of characters 73 00:06:25,230 --> 00:06:25,850 or letters. 74 00:06:26,210 --> 00:06:32,380 We will need to take things a step further and scramble the characters in the message to do that. 75 00:06:32,730 --> 00:06:36,330 Let us first learn a bit more about what our list.