1 00:00:00,490 --> 00:00:06,990 Now we come to reading the input file now here, after we have checked this, we are giving them the 2 00:00:07,000 --> 00:00:11,140 file object astar to open the input, find the Mystere content. 3 00:00:11,140 --> 00:00:15,400 They start to read the file object, STF and Kluth. 4 00:00:15,640 --> 00:00:18,370 Then we are printing your print matter. 5 00:00:18,700 --> 00:00:21,990 So in this we are opening the file stored in the input finder. 6 00:00:22,000 --> 00:00:26,240 Mr. Read its content into the variable and then close the file. 7 00:00:26,500 --> 00:00:33,070 And after reading in the file the output in a message for the user telling them that the encryption 8 00:00:33,070 --> 00:00:34,690 on the decryption has begun. 9 00:00:35,080 --> 00:00:41,440 Now because you're my more astar variable should either contain the string encrypt or decrypt calling 10 00:00:41,440 --> 00:00:49,030 the title string method capitalizes the first letter of the string in my Monastir and slices the string 11 00:00:49,030 --> 00:00:51,850 in two percent, saying it's a string. 12 00:00:52,120 --> 00:00:56,370 So it either displays so encrypting or decrypting. 13 00:00:56,560 --> 00:00:57,400 Dot, dot, dot. 14 00:00:57,910 --> 00:01:01,310 So this is what it would be added to it at the end of it. 15 00:01:01,810 --> 00:01:05,750 Now coming to measuring the time it took to encrypt or decrypt. 16 00:01:06,100 --> 00:01:13,150 So over here we will check the encrypting or decrypting an entire file can take much longer than a short 17 00:01:13,150 --> 00:01:13,530 string. 18 00:01:13,900 --> 00:01:18,070 So a user might want to know how long the process takes, four or five. 19 00:01:18,550 --> 00:01:22,340 We can measure the length of the encryption or decryption by using the time. 20 00:01:23,320 --> 00:01:28,540 So here the time module and the time the time function, let us further discuss that and then we would 21 00:01:28,540 --> 00:01:29,170 come to this. 22 00:01:29,500 --> 00:01:35,830 Now, the time, the time function returns, the current time as of load value of the number of seconds 23 00:01:36,070 --> 00:01:38,570 since January one, 1970. 24 00:01:39,100 --> 00:01:41,800 Now, this moment is called the Unix approach. 25 00:01:42,220 --> 00:01:46,760 Now you can enter something in the interactive shell to see how the function works. 26 00:01:47,050 --> 00:01:56,350 So let's go back here and we will try to first see import time here and we would see time dot time will 27 00:01:56,350 --> 00:01:57,760 give you this particular value. 28 00:01:58,030 --> 00:02:04,420 Or if you again, the time, the time, it will automatically increase now because time dot time returns 29 00:02:04,420 --> 00:02:09,950 a flawed number, it can be precise, up to seven, one thousand of a second. 30 00:02:10,240 --> 00:02:16,810 Of course, the numbers that time, the time display depends on the moment in time that you call this 31 00:02:16,810 --> 00:02:19,510 function and may be difficult to interpret. 32 00:02:19,780 --> 00:02:25,600 It might not be clear that a particular value is on Monday or Tuesday or something like that or some 33 00:02:25,600 --> 00:02:27,580 particular day to do so. 34 00:02:27,580 --> 00:02:28,760 Horrible time. 35 00:02:28,760 --> 00:02:34,540 But time function is useful for comparing the number of seconds between calls to time to time. 36 00:02:35,230 --> 00:02:38,990 We can use this function to determine how long the program has been running. 37 00:02:39,310 --> 00:02:45,750 For example, if you subtract the floating point, values returned when we call the first time, the 38 00:02:45,760 --> 00:02:53,260 time in the interactive shell, for example, over here, if we see this particular value recopy down 39 00:02:53,260 --> 00:02:56,980 here, we say minus this particular value. 40 00:02:58,200 --> 00:03:00,210 Copy down and press enter. 41 00:03:00,450 --> 00:03:02,600 So this is what is the time lapse? 42 00:03:03,000 --> 00:03:07,930 So now we come to our core where we're using the time load time function in our program. 43 00:03:08,370 --> 00:03:10,470 So here we you will start. 44 00:03:10,470 --> 00:03:11,640 Time is equal time. 45 00:03:11,640 --> 00:03:16,080 What time it returns the current time to store it in a variable name start time. 46 00:03:16,500 --> 00:03:23,480 Then we call the if statement here to encrypt or decrypt the particular file that we have passed. 47 00:03:23,850 --> 00:03:27,300 And again after the program encryption decryption has done. 48 00:03:27,630 --> 00:03:33,870 We are again calling after that time the time method which is over here, which is total Demoustier. 49 00:03:33,870 --> 00:03:39,150 We are seeing around the time, the time minus start time I rounded off to do the. 50 00:03:39,990 --> 00:03:43,680 So the result is a number of seconds between the two calls of time. 51 00:03:43,680 --> 00:03:49,980 The time that is the start time expression evaluates to a value that is passed on to the wrong function, 52 00:03:50,250 --> 00:03:56,250 which runs to the nearest two decimal point, because we don't need a millisecond precision for the 53 00:03:56,250 --> 00:03:56,700 program. 54 00:03:57,030 --> 00:03:59,880 And this value is now stored in total Demoustier. 55 00:04:00,330 --> 00:04:05,190 So now the users are going to string splice linked to put in the program more and display to the user 56 00:04:05,190 --> 00:04:09,140 the amount of time it took for the program to encrypt decrypt. 57 00:04:09,600 --> 00:04:13,320 Then we go ahead for writing the output to the file. 58 00:04:13,740 --> 00:04:20,450 So the encrypted, already encrypted file contents are now stored in the variable named translated Istria. 59 00:04:20,910 --> 00:04:24,240 But this string is forgotten when the program terminates. 60 00:04:24,480 --> 00:04:30,590 So we want to store the string in a file to have even after the program has finished learning or running. 61 00:04:30,840 --> 00:04:37,450 So after that we open a particular file in the output file will be gesture, which is open enough. 62 00:04:37,480 --> 00:04:37,950 Right. 63 00:04:38,670 --> 00:04:45,270 And then we call the right file object, the method there and again, closed before and after this. 64 00:04:45,270 --> 00:04:51,960 It prints similar messages to the user indicating that the process is done and the name of the file 65 00:04:51,960 --> 00:04:52,660 is written. 66 00:04:52,920 --> 00:04:59,640 So after this, we are printing here that done whatever mode that is encrypting or decrypting into the 67 00:04:59,640 --> 00:05:05,640 particular file, reprint, print, the length of the file and also the characters, which are how many 68 00:05:05,640 --> 00:05:07,380 characters it has been written to the file. 69 00:05:07,590 --> 00:05:15,090 And finally we see it is completed or the encrypted or the decrypted file is whatever is the filename 70 00:05:15,090 --> 00:05:15,310 there. 71 00:05:15,840 --> 00:05:22,260 With this, we come to the last part of our program wherein we are calling the main method, which is 72 00:05:22,500 --> 00:05:27,240 again called the main function if the program is being run instead of being important. 73 00:05:27,630 --> 00:05:30,590 So this is again, similar as to what we have done now. 74 00:05:31,020 --> 00:05:40,340 So now, for example, the one file that we have C we take it as the input file, as a vector to extend. 75 00:05:40,740 --> 00:05:42,840 And here we will take it to ABC. 76 00:05:44,280 --> 00:05:55,170 Encrypted text, and we're supposed to encrypt the process and after this, now let us sprint execute 77 00:05:55,170 --> 00:05:55,940 this once again. 78 00:05:56,430 --> 00:06:01,350 So we will, first of all, save this and run the. 79 00:06:03,090 --> 00:06:05,960 Now, here we are saying encrypting encryption time. 80 00:06:05,970 --> 00:06:06,600 Is this done? 81 00:06:06,600 --> 00:06:12,360 Encrypting ABC, that is one of six characters and encrypted file is absolutely encrypted. 82 00:06:12,360 --> 00:06:15,870 But let's have a look in our fight and hacking. 83 00:06:16,330 --> 00:06:21,450 We have this ABC encrypted file that we have written later on that we had created. 84 00:06:21,450 --> 00:06:22,810 We have encrypted that fight. 85 00:06:23,160 --> 00:06:29,990 Now, again, if you have to decrypt the same file, you have to write down here the input filename 86 00:06:30,000 --> 00:06:32,680 as this instead of a normal. 87 00:06:33,540 --> 00:06:37,040 And now you won't say, oh, decrypted file here. 88 00:06:37,320 --> 00:06:41,870 And the process you want to do is not encrypted, but decrypt. 89 00:06:42,150 --> 00:06:45,190 So let us save this again and run the audio. 90 00:06:45,960 --> 00:06:48,990 So now we have a backdoor decrypted the extreme. 91 00:06:49,260 --> 00:06:55,470 So let's again check whether the file is there and in the normal position of this file and ABC file 92 00:06:56,010 --> 00:06:57,210 should exactly match. 93 00:06:57,220 --> 00:07:02,130 That is how the file has properly encrypted and decrypted itself. 94 00:07:02,520 --> 00:07:06,630 So another simple example that we have done by just changing the finding them that we have. 95 00:07:06,840 --> 00:07:14,040 So any file you can take with whatever data you have, same file for encryption, the encrypted file 96 00:07:14,040 --> 00:07:19,710 later on, pass it as an input filename and create another decrypted finding them to get the output 97 00:07:19,710 --> 00:07:20,070 for it. 98 00:07:20,550 --> 00:07:28,110 So in this way, we have completed the python hacking beginner level code wherein we have covered the 99 00:07:28,290 --> 00:07:30,410 reverse cipher we have covered. 100 00:07:30,420 --> 00:07:31,470 This is a cipher. 101 00:07:31,770 --> 00:07:34,350 Also seeing how to hack with Cesar Saiful. 102 00:07:34,710 --> 00:07:41,610 We have worked on encrypting with the transposition cipher again, decrypting using transposition cipher. 103 00:07:41,940 --> 00:07:47,940 We have seen a program which would run a transposition cipher a number of times with different parameters 104 00:07:47,940 --> 00:07:51,910 on it and get the output with different key and the message parameters. 105 00:07:52,170 --> 00:07:56,790 And finally, how to encrypt or decrypt a particular file in Python. 106 00:07:57,210 --> 00:08:02,670 So with this, we have covered the beginner level, which will give you a start of the start in how 107 00:08:02,670 --> 00:08:04,470 to hack using Python. 108 00:08:04,980 --> 00:08:06,520 So that's it from this session. 109 00:08:06,540 --> 00:08:07,470 Thank you very much.