1 00:00:01,020 --> 00:00:08,220 Now, we'll move to the last session in our first week in that level of python hacking that is encrypting 2 00:00:08,220 --> 00:00:15,900 and decrypting using files now in the previous session, we have all created programs that have only 3 00:00:15,900 --> 00:00:21,730 worked on small messages that we tied directly into the code files as some string values. 4 00:00:22,230 --> 00:00:28,560 Now, the Saiful programs will make in this session will allow you to encrypt and decrypt the entire 5 00:00:28,560 --> 00:00:32,120 file, which can have millions of characters insights. 6 00:00:32,730 --> 00:00:38,460 Also, along with this, the following topics would be covered in the session that is using the open 7 00:00:38,460 --> 00:00:45,990 function, reading and writing files, using the right close and read file object methods, using the 8 00:00:46,320 --> 00:00:52,020 stockpot dot exit function, using law and title string methods. 9 00:00:52,350 --> 00:00:55,530 Using this starts with and with string methods. 10 00:00:55,860 --> 00:00:59,630 Also the time module and the time or time function. 11 00:01:00,120 --> 00:01:06,420 Now, understanding what our plain text files, the transposition file cipher program, encrypt and 12 00:01:06,420 --> 00:01:08,240 decrypt the plain text files. 13 00:01:08,610 --> 00:01:16,740 Now these are the kind of files that only have some text data and usually have ordered the text as the 14 00:01:16,740 --> 00:01:17,720 file extension. 15 00:01:18,060 --> 00:01:25,530 You can write your own text files with programs such as Notepad on Windows or text edit on Mac OS or 16 00:01:25,560 --> 00:01:25,950 G. 17 00:01:25,950 --> 00:01:27,480 Edit on Linux. 18 00:01:27,990 --> 00:01:35,100 Now you can even use the Idalis file ed by saving the file within the next extension instead of the 19 00:01:35,100 --> 00:01:37,620 usual DOT by extension. 20 00:01:38,160 --> 00:01:45,090 Now we'll use some simple text files in this particular session which will have certain characters or 21 00:01:45,090 --> 00:01:50,400 data already there, which we are only using for encrypting it and again to decrypt it. 22 00:01:50,760 --> 00:01:57,390 So in this particular session where we'll be covering the module, but also if you just look at our 23 00:01:57,750 --> 00:02:00,180 python hacking beginner folder. 24 00:02:00,830 --> 00:02:06,210 So in this python hacking big enough, although we are having this the to fight, which is having some 25 00:02:06,210 --> 00:02:12,870 text data into it, which we are going to use in our session for encrypting and again for decrypting 26 00:02:12,870 --> 00:02:13,330 it also. 27 00:02:14,010 --> 00:02:21,330 So we will first of all, create the program for transposition file cipher for encrypting it and decrypting 28 00:02:21,330 --> 00:02:21,430 it. 29 00:02:21,960 --> 00:02:25,460 So let us go back here and we'll go for a new file. 30 00:02:25,830 --> 00:02:31,580 And here we will have to again import our Lemington and then we'll talk in here also. 31 00:02:31,890 --> 00:02:34,980 But and before that, we will say import time. 32 00:02:35,580 --> 00:02:42,020 Safeway's slash sis slash our demo then and demo 30. 33 00:02:42,300 --> 00:02:55,440 And after this, we define the main method wherein we give the input file name SDR as equal to our dummy 34 00:02:55,500 --> 00:03:01,350 dog, the X, and we have placed this in the same folder where we are to save the current fight. 35 00:03:01,690 --> 00:03:06,720 Otherwise be careful to give the whole back if it is not existing again. 36 00:03:06,930 --> 00:03:09,960 If the file is not existing, you will get an error. 37 00:03:09,960 --> 00:03:14,610 So be sure that the files existing in your particular folder. 38 00:03:15,060 --> 00:03:17,700 Now this is the input filename that we have given. 39 00:03:17,970 --> 00:03:27,990 Similarly, we also require some output filename SDR and here we would be giving, say, dummy dot. 40 00:03:29,610 --> 00:03:37,140 Encrypted dot the just to make it a difference that the earlier one is a normal file and this is our 41 00:03:37,140 --> 00:03:45,990 encrypted file, hence we have given the file name, got encrypted, got the then we give the same A 42 00:03:46,620 --> 00:03:47,700 that's equal to. 43 00:03:48,090 --> 00:03:58,050 Let's give our kids it then and say my Modesta SDR is equal to we are first of all doing it and so forth. 44 00:03:58,050 --> 00:04:04,490 Time when we are doing it and we are setting to enter if we want to decrypt said this value to decrypt. 45 00:04:04,920 --> 00:04:10,320 So we will do that later on when we would really gripping it the coming to the next one. 46 00:04:10,620 --> 00:04:14,440 Now if the file input does not exist, the program would dominate. 47 00:04:14,820 --> 00:04:23,220 So for that we are checking, if not the OS dot, the part does not exist. 48 00:04:23,520 --> 00:04:29,110 And in this you give the FI input file name as DIA parameter. 49 00:04:29,400 --> 00:04:36,630 So if it is not existing, we are giving an appropriate message to the user seeing the file zipless 50 00:04:36,630 --> 00:04:46,230 and which is C does not exist and quiting. 51 00:04:48,160 --> 00:04:50,770 The program 52 00:04:54,820 --> 00:05:06,830 and the audio give in person format the value of the input filename SDR, after which we say here this 53 00:05:06,880 --> 00:05:11,480 does not exist, which will exit the particular program totally. 54 00:05:11,650 --> 00:05:16,410 And if the output file already exists, give the user a chance to quit. 55 00:05:16,440 --> 00:05:21,480 So, again, the output file should also be not existing because we are creating the file there. 56 00:05:21,820 --> 00:05:32,560 So for that, we will check in another if seeing if this dot, dot, dot exist and here we give the 57 00:05:32,950 --> 00:05:37,390 output file name is still variable. 58 00:05:37,900 --> 00:05:44,020 Then we give your print message as see this will. 59 00:05:46,620 --> 00:05:47,340 Over right. 60 00:05:52,900 --> 00:06:00,630 OK, the fine print here wasn't s and in this we give C. 61 00:06:03,420 --> 00:06:14,850 Continue or in fact, kill for fuckwit, give this to the user as a message and put in their output 62 00:06:15,810 --> 00:06:25,860 filename STF, then whatever the response, the user gives your distorted in the response, your variable 63 00:06:26,160 --> 00:06:29,070 by taking the input and. 64 00:06:32,230 --> 00:06:48,220 And then after which we say, if not, the response is still dot law, dot starts with B, C, C, then 65 00:06:48,430 --> 00:06:51,020 you say start, exit again. 66 00:06:51,970 --> 00:07:01,390 Otherwise, if everything is proper, then we'll go here and create another file or SDR and we will 67 00:07:01,600 --> 00:07:06,810 open the file that we are passed to input filename still. 68 00:07:07,120 --> 00:07:12,180 So if the file is there, everything is proper, then you pass that to the file object. 69 00:07:12,520 --> 00:07:18,100 And again, the value for content SDR would be your file object. 70 00:07:18,100 --> 00:07:25,130 SDR not using the Rudimental and the file or SDR dot. 71 00:07:25,300 --> 00:07:29,280 Don't forget to close it after it has read it successfully. 72 00:07:29,650 --> 00:07:39,300 So once that is done, we go on for print and in this we say print and percentage see assaying. 73 00:07:39,970 --> 00:07:47,410 But in the valley of say my more now here that is my mode. 74 00:07:47,480 --> 00:07:50,550 Still not see item.