1 00:00:00,420 --> 00:00:08,310 Welcome to the next session in our Biton hacking class that is programming a program to test your particular 2 00:00:08,520 --> 00:00:09,030 program. 3 00:00:09,480 --> 00:00:16,680 So now here, the transposition program seems to work pretty well at encrypting and decrypting different 4 00:00:16,680 --> 00:00:19,170 messages with various keys. 5 00:00:19,470 --> 00:00:21,090 But how do you know? 6 00:00:21,210 --> 00:00:22,350 They always will? 7 00:00:22,710 --> 00:00:30,040 Now, you cannot be absolutely sure the program always work unless you test the encrypt message and 8 00:00:30,040 --> 00:00:35,310 the decrypt message functions with all sorts of message and keep it amateur values. 9 00:00:35,610 --> 00:00:42,150 But this will take a lot of time because you would have to type a message in an encryption program, 10 00:00:42,390 --> 00:00:43,200 said Thuggy. 11 00:00:43,470 --> 00:00:51,570 Run the encryption program then based ciphertext into the decryption program, said the key, and then 12 00:00:51,570 --> 00:00:53,010 run the decryption program. 13 00:00:53,340 --> 00:01:00,060 You would also need to repeat that process with several different keys and messages, resulting in a 14 00:01:00,060 --> 00:01:01,650 lot of boring work. 15 00:01:01,950 --> 00:01:10,200 Now, instead of this, we can write down another program that can generate a random message and a random 16 00:01:10,200 --> 00:01:12,820 key to test the cipher programs. 17 00:01:13,170 --> 00:01:20,640 Now these programs will encrypt the message using the encrypted message matter and then pass that particular 18 00:01:20,640 --> 00:01:23,650 ciphertext to your decrypt message matter. 19 00:01:23,970 --> 00:01:31,500 And if a plain text written by the decrypt message the same as the original message, then the program 20 00:01:31,500 --> 00:01:36,690 will know that the encryption and the decryption program have voted no. 21 00:01:37,050 --> 00:01:43,950 The process of testing a program automatically using another program is called the Automated Testing. 22 00:01:44,420 --> 00:01:51,630 Now several different messages and key combinations need to be tried, but it takes the computer only 23 00:01:51,630 --> 00:01:54,900 a minute or so to test thousands of combinations. 24 00:01:55,170 --> 00:02:01,670 So if all those test pass, then you can be more certain that your code has locked it. 25 00:02:01,770 --> 00:02:08,520 Now to the cover this particular session, which would be also covering the random go round end function, 26 00:02:08,850 --> 00:02:10,870 the random seed function. 27 00:02:11,310 --> 00:02:14,580 We will also see what are different types of list of references. 28 00:02:14,910 --> 00:02:21,750 We will cover the copied or deep copy functions, random code shuffle function, randomly scrambling 29 00:02:21,750 --> 00:02:25,440 a particular string and system exit function. 30 00:02:25,680 --> 00:02:33,580 OK, so now we would come for writing down a particular code for testing our transposition program. 31 00:02:34,200 --> 00:02:38,760 So here we would go for a new file and we would type. 32 00:02:38,760 --> 00:02:42,850 First thing we required is import random. 33 00:02:43,350 --> 00:02:52,110 Then since then trons position encrypt and 34 00:02:54,270 --> 00:02:57,120 transposition decrypt. 35 00:02:57,790 --> 00:03:01,380 Now we would be defining the main method here. 36 00:03:02,100 --> 00:03:11,660 Inside this, let us use the random dot seed function and here we are giving sailele static value for 37 00:03:11,790 --> 00:03:11,880 you. 38 00:03:12,570 --> 00:03:19,050 Now this is, we have said the random C to a static value that we have set it here, not below this. 39 00:03:19,140 --> 00:03:22,290 We would run a for loop which will go in a range. 40 00:03:24,320 --> 00:03:31,460 And between 20, so we're basically going to run 20 test for this encryption and decryption process, 41 00:03:31,670 --> 00:03:36,330 so this will generate some random messages which will be helpful for us to testing. 42 00:03:36,890 --> 00:03:45,080 And then if you go inside the for loop here, we would create a single message SDR that is equal to 43 00:03:45,440 --> 00:03:47,720 let's give some capital numbers. 44 00:03:48,620 --> 00:03:56,810 So g h i j k l and if you want Rusty, you've W, X, Y and Z. 45 00:03:57,380 --> 00:03:59,270 Now we have given everything into capital. 46 00:03:59,270 --> 00:04:03,020 Then here we say multiply multiplied by random dot. 47 00:04:04,060 --> 00:04:11,920 Decline in function, but we are passing for coma for now, this message that we have created will also 48 00:04:11,920 --> 00:04:14,000 have a random length for that length. 49 00:04:14,020 --> 00:04:16,840 We have defined it over here after this. 50 00:04:16,840 --> 00:04:26,860 In the next line, we would say same message as we will do list in bracket message, as are now. 51 00:04:26,860 --> 00:04:33,360 He'll be able to convert the message Asgeir string to a list which will be basically used to shuffle. 52 00:04:33,790 --> 00:04:39,780 And then after this we would use the random dot shuffle function. 53 00:04:40,120 --> 00:04:49,870 And in this also we would pass the message STF now after we have shuffle this, we will create a message 54 00:04:49,870 --> 00:04:57,640 as hour is equal to blank, then dot join and again, let's give your message Asgeir. 55 00:04:57,850 --> 00:05:05,240 Now this is basically used to convert the list back to string and then don't forget to give up command. 56 00:05:05,260 --> 00:05:18,250 Here we are giving the best hash we put into your 10 percent as colon double code as close this single 57 00:05:18,250 --> 00:05:23,260 code, give your bracket five plus one comma. 58 00:05:23,980 --> 00:05:34,220 The value of message estie are all 50 in square brackets and let's close the round bracket. 59 00:05:34,600 --> 00:05:39,350 Now, after this, we will have to check for all the possible keys for each message. 60 00:05:39,670 --> 00:05:46,690 So for that we would go for 60 are in our range. 61 00:05:46,720 --> 00:05:51,040 We are giving you starting from one and converting it to integer. 62 00:05:51,460 --> 00:05:57,840 The length of your message, Estie, are divided by two. 63 00:05:58,240 --> 00:06:00,610 And after this, let's create your. 64 00:06:01,610 --> 00:06:04,960 So encrypted a that's equal to now. 65 00:06:04,970 --> 00:06:12,440 Here we are going to use the transposition, say, transposition and grip dot. 66 00:06:12,980 --> 00:06:17,920 We will use the encrypted message method and we will pass here. 67 00:06:17,960 --> 00:06:25,220 The key is here and the message is still whatever the value will be written will be stored in this encrypted 68 00:06:25,220 --> 00:06:25,700 Ostia. 69 00:06:25,970 --> 00:06:29,590 Similarly, here, we will use decrypted Ostia. 70 00:06:29,630 --> 00:06:33,250 That's equal to psytrance position. 71 00:06:34,050 --> 00:06:40,190 Use the decrypt, not decrypt message. 72 00:06:40,490 --> 00:06:42,920 And again, helth will use the key here. 73 00:06:42,920 --> 00:06:50,420 But now for decrypting, it will have to pass the value that this encrypted SD card here does so that 74 00:06:50,420 --> 00:06:52,980 the same encrypted text would be again decrypted. 75 00:06:53,360 --> 00:06:58,460 So if the decryption doesn't match the original message, we have to display an error message and we'll 76 00:06:58,460 --> 00:06:59,090 have to quit. 77 00:06:59,390 --> 00:07:03,950 So now after this, we will have to go for another safe. 78 00:07:04,430 --> 00:07:06,140 Checking for the message. 79 00:07:06,140 --> 00:07:13,730 Astarte, if that is not equal to your decrypted SDR, then what are you supposed to do? 80 00:07:14,060 --> 00:07:26,720 We will give your opponent saying, say, mismatch with GISTARO percent s and message SDR wasn't as 81 00:07:27,200 --> 00:07:37,090 Clouzot and put into the values of still comma messages dear after this Nibelungen print. 82 00:07:37,100 --> 00:07:49,310 Another saying the decrypted US Colen close this and printed the value of decrypted STF. 83 00:07:50,090 --> 00:07:53,540 And after this we would say Stop it. 84 00:07:54,530 --> 00:08:03,440 Now, once this is done, the next thing we'll have to do is let's come out of this and move back in 85 00:08:03,440 --> 00:08:04,490 the for loop. 86 00:08:08,440 --> 00:08:24,850 Here and here, we would be printing see the transposition cipher text has passed successfully. 87 00:08:25,990 --> 00:08:30,270 That will be the end of this particular session that we have defined the main method.