1 00:00:00,300 --> 00:00:06,180 By the time the for loop is done, looping the ciphertext is variable will contain the complete string 2 00:00:06,180 --> 00:00:08,010 of encrypted message. 3 00:00:08,160 --> 00:00:13,740 So on each iteration of the loop symbols, variable is assigned a single character from the message 4 00:00:13,800 --> 00:00:14,240 Istria. 5 00:00:14,490 --> 00:00:21,060 If this character exists in Symbolistic, which is our symbol, set the index and symbols Izturis is 6 00:00:21,420 --> 00:00:28,860 and assigned to the symbol next on the next line over here where we are checking that that to encrypt 7 00:00:28,860 --> 00:00:37,430 the text, we need to calculate the index of the encrypted letter so we'll see the symbol index by key 8 00:00:37,590 --> 00:00:38,060 A1. 9 00:00:38,220 --> 00:00:48,000 And if we add it to be able to produce the given output and then it more to the result by the size of 10 00:00:48,000 --> 00:00:52,140 your symbols that represented by expression length in brackets. 11 00:00:52,140 --> 00:00:58,860 Symbolistic know modding by Lance Embellisher handles the wraparound by ensuring the calculated index 12 00:00:59,100 --> 00:01:04,460 is always between zero and up to, but not including the length of symbolistic. 13 00:01:04,890 --> 00:01:10,650 So the resulting number will be indexed in the simplicity of the encrypted character would just concatenate 14 00:01:10,650 --> 00:01:13,090 them to the end of the string in your ciphertext. 15 00:01:13,090 --> 00:01:13,580 Hestia. 16 00:01:13,980 --> 00:01:21,780 So everything in the previous that we have seen is done using a single line of code over here Modeselektor. 17 00:01:22,380 --> 00:01:28,230 So if your symbol isn't an obvious implicit symbol is concatenated to the end of the ciphertext or what 18 00:01:29,100 --> 00:01:34,920 else, the quotation marks on the hyphen in the original message are not in the symbols set and therefore 19 00:01:34,920 --> 00:01:37,120 they are concatenated directly to the string. 20 00:01:37,620 --> 00:01:43,390 So after this code is iterate through each character in the message string ciphertext, Astarita should 21 00:01:43,440 --> 00:01:51,530 contain the full encrypted string which returns encrypted string from the particular function that this 22 00:01:51,780 --> 00:01:52,770 encrypt messages. 23 00:01:53,190 --> 00:01:56,740 So now let us understand writing the decryption function. 24 00:01:57,060 --> 00:02:00,630 So here we have returned this value for the encrypt messages. 25 00:02:00,920 --> 00:02:08,250 OK, now you're the decrypt message start function that the crypto text is almost the same as our encrypt 26 00:02:08,250 --> 00:02:08,690 messages. 27 00:02:09,330 --> 00:02:11,370 So here we have this keys. 28 00:02:11,610 --> 00:02:18,930 We check the key estar, we create a plain text and here we are using the crypto one for finding the 29 00:02:18,940 --> 00:02:19,740 more involved. 30 00:02:19,830 --> 00:02:27,930 OK, so instead of multiplying by even the decryption process multiplies by the modular inverse of the 31 00:02:27,930 --> 00:02:33,630 more inverse is calculated by calling the crypto math one don't find more inverse, which we have already 32 00:02:33,630 --> 00:02:34,920 seen in the earlier session. 33 00:02:35,460 --> 00:02:42,210 Now after this, if you see the for loop, this is almost identical to the message is still the only 34 00:02:42,210 --> 00:02:48,600 difference comes over here when in the encrypt message, the symbol index was multiplied by one and 35 00:02:48,600 --> 00:02:55,590 then he even was added to it in the decrypt message function, the symbol index post, subtract the 36 00:02:56,070 --> 00:02:57,330 key one over here. 37 00:02:57,630 --> 00:03:04,110 And so subtracting after the key, even from the simple index, and then it multiplies it by remodeler 38 00:03:04,110 --> 00:03:10,240 and then add more to this number the size of your symbols, and that is the length of your symbolistic. 39 00:03:10,800 --> 00:03:14,550 Now this is how the decryption process undoes the encryption. 40 00:03:14,910 --> 00:03:21,960 Now let us look at how we can change it so it can randomly select the valid keys for a fine Saiful So 41 00:03:21,960 --> 00:03:24,690 we move on to generating the random keys. 42 00:03:25,260 --> 00:03:31,910 Now if you look at over here in your program, we have this get random ATSDR. 43 00:03:32,400 --> 00:03:38,790 Now it can be difficult to come up with a valid GUI for a fine cipher so you can instead use the get 44 00:03:38,790 --> 00:03:46,770 random estar function to generate a random butta wanted to do this, simply change that to this particular 45 00:03:46,770 --> 00:03:54,270 lake here we are seeing now if we just go about we are giving here see the value of my guest out here 46 00:03:54,540 --> 00:03:59,370 now instead of giving a key value here, we can see all this get. 47 00:04:00,630 --> 00:04:13,380 Now, how have you define this, get random to give this and also we are giving here 60 percent is and 48 00:04:13,380 --> 00:04:16,920 we are presenting the value in the mixture. 49 00:04:17,160 --> 00:04:22,980 So now the program randomly selects and printed to the screen when it executes. 50 00:04:23,010 --> 00:04:25,590 Now, let us look at how they get random function. 51 00:04:25,590 --> 00:04:29,170 VOKES So let us go below and compare this function here. 52 00:04:29,460 --> 00:04:36,280 We have entered a loop in this very condition is through this infinite loop will loop forever until 53 00:04:36,280 --> 00:04:39,900 it is told to return to the user terminates the program. 54 00:04:40,170 --> 00:04:45,600 Now, if your program gets stuck in an infinite loop, you can dominate the program by placing controls 55 00:04:46,350 --> 00:04:47,330 on windows. 56 00:04:47,340 --> 00:04:53,970 OK, so get the random can function will eventually exit the infinite loop with the written statement. 57 00:04:54,330 --> 00:05:01,000 Now here we are determining the random numbers between two and the size of the symbols set for each 58 00:05:01,030 --> 00:05:02,640 event and V1. 59 00:05:02,970 --> 00:05:09,670 Now this code ensures that there is no chance that even a B one will be equal to the invalid value zero 60 00:05:09,670 --> 00:05:10,080 or one. 61 00:05:10,530 --> 00:05:18,660 The if statement checks over here that we have given it checks to make sure that the key is relatively 62 00:05:18,660 --> 00:05:25,170 primed with the size of the symbols set by calling the GCD function in the Cryptome at one module if 63 00:05:25,220 --> 00:05:32,040 given is relatively with the size of superset, then these two randomly selected keys are combined into 64 00:05:32,040 --> 00:05:38,490 a single schema multiplying given by the same size and adding we want to the product over here. 65 00:05:39,060 --> 00:05:45,000 Now this particular line that is a written statement, it basically returns the value from the get random 66 00:05:45,240 --> 00:05:46,260 astar function. 67 00:05:46,680 --> 00:05:53,010 Now, if the conditioned response was the old loops back to the start of the pilot and picks a random 68 00:05:53,010 --> 00:05:59,190 number for each one, and we want to give infinite loop, and that program continues looping until it 69 00:05:59,190 --> 00:06:02,250 finds random numbers that are also valid. 70 00:06:02,850 --> 00:06:09,060 Now, after that, the next thing that we have is just the similar one, which is calling the main function 71 00:06:09,060 --> 00:06:13,260 of this program was run by itself rather than being imported by another program. 72 00:06:13,680 --> 00:06:19,380 So this ensures that the main function runs when the program is running, but not when the program is 73 00:06:19,380 --> 00:06:20,550 important as a module. 74 00:06:20,880 --> 00:06:24,630 So now if we try to execute this. 75 00:06:26,150 --> 00:06:33,800 Now, we have done this for decrypting let us go back for encryption, so now we have used see the keys 76 00:06:34,160 --> 00:06:37,590 to seven to three in this case and the decrypted extras over here. 77 00:06:37,880 --> 00:06:43,940 So let's go back here and let's write down all proper text. 78 00:06:44,420 --> 00:06:45,950 Let's let this. 79 00:06:47,590 --> 00:06:49,840 And right down here. 80 00:06:50,440 --> 00:07:08,830 So this is and simple program for a fine Saiful encryption of the text, you will see the 81 00:07:11,800 --> 00:07:12,580 output. 82 00:07:15,850 --> 00:07:29,140 Shortly after executing Let's save this and we will change this to and let us run this. 83 00:07:30,040 --> 00:07:37,210 So now what gate has used for three three three is the Valerica, which it has used for encrypting this 84 00:07:37,210 --> 00:07:38,410 particular message. 85 00:07:38,740 --> 00:07:40,950 So with this, we have completed the spot. 86 00:07:40,960 --> 00:07:46,210 Now we will move on to the next session where we will see hacking this afine Saiful.