Now we come to reading the input file now here, after we have checked this, we are giving them the
file object astar to open the input, find the Mystere content.
They start to read the file object, STF and Kluth.
Then we are printing your print matter.
So in this we are opening the file stored in the input finder.
Mr. Read its content into the variable and then close the file.
And after reading in the file the output in a message for the user telling them that the encryption
on the decryption has begun.
Now because you're my more astar variable should either contain the string encrypt or decrypt calling
the title string method capitalizes the first letter of the string in my Monastir and slices the string
in two percent, saying it's a string.
So it either displays so encrypting or decrypting.
Dot, dot, dot.
So this is what it would be added to it at the end of it.
Now coming to measuring the time it took to encrypt or decrypt.
So over here we will check the encrypting or decrypting an entire file can take much longer than a short
string.
So a user might want to know how long the process takes, four or five.
We can measure the length of the encryption or decryption by using the time.
So here the time module and the time the time function, let us further discuss that and then we would
come to this.
Now, the time, the time function returns, the current time as of load value of the number of seconds
since January one, 1970.
Now, this moment is called the Unix approach.
Now you can enter something in the interactive shell to see how the function works.
So let's go back here and we will try to first see import time here and we would see time dot time will
give you this particular value.
Or if you again, the time, the time, it will automatically increase now because time dot time returns
a flawed number, it can be precise, up to seven, one thousand of a second.
Of course, the numbers that time, the time display depends on the moment in time that you call this
function and may be difficult to interpret.
It might not be clear that a particular value is on Monday or Tuesday or something like that or some
particular day to do so.
Horrible time.
But time function is useful for comparing the number of seconds between calls to time to time.
We can use this function to determine how long the program has been running.
For example, if you subtract the floating point, values returned when we call the first time, the
time in the interactive shell, for example, over here, if we see this particular value recopy down
here, we say minus this particular value.
Copy down and press enter.
So this is what is the time lapse?
So now we come to our core where we're using the time load time function in our program.
So here we you will start.
Time is equal time.
What time it returns the current time to store it in a variable name start time.
Then we call the if statement here to encrypt or decrypt the particular file that we have passed.
And again after the program encryption decryption has done.
We are again calling after that time the time method which is over here, which is total Demoustier.
We are seeing around the time, the time minus start time I rounded off to do the.
So the result is a number of seconds between the two calls of time.
The time that is the start time expression evaluates to a value that is passed on to the wrong function,
which runs to the nearest two decimal point, because we don't need a millisecond precision for the
program.
And this value is now stored in total Demoustier.
So now the users are going to string splice linked to put in the program more and display to the user
the amount of time it took for the program to encrypt decrypt.
Then we go ahead for writing the output to the file.
So the encrypted, already encrypted file contents are now stored in the variable named translated Istria.
But this string is forgotten when the program terminates.
So we want to store the string in a file to have even after the program has finished learning or running.
So after that we open a particular file in the output file will be gesture, which is open enough.
Right.
And then we call the right file object, the method there and again, closed before and after this.
It prints similar messages to the user indicating that the process is done and the name of the file
is written.
So after this, we are printing here that done whatever mode that is encrypting or decrypting into the
particular file, reprint, print, the length of the file and also the characters, which are how many
characters it has been written to the file.
And finally we see it is completed or the encrypted or the decrypted file is whatever is the filename
there.
With this, we come to the last part of our program wherein we are calling the main method, which is
again called the main function if the program is being run instead of being important.
So this is again, similar as to what we have done now.
So now, for example, the one file that we have C we take it as the input file, as a vector to extend.
And here we will take it to ABC.
Encrypted text, and we're supposed to encrypt the process and after this, now let us sprint execute
this once again.
So we will, first of all, save this and run the.
Now, here we are saying encrypting encryption time.
Is this done?
Encrypting ABC, that is one of six characters and encrypted file is absolutely encrypted.
But let's have a look in our fight and hacking.
We have this ABC encrypted file that we have written later on that we had created.
We have encrypted that fight.
Now, again, if you have to decrypt the same file, you have to write down here the input filename
as this instead of a normal.
And now you won't say, oh, decrypted file here.
And the process you want to do is not encrypted, but decrypt.
So let us save this again and run the audio.
So now we have a backdoor decrypted the extreme.
So let's again check whether the file is there and in the normal position of this file and ABC file
should exactly match.
That is how the file has properly encrypted and decrypted itself.
So another simple example that we have done by just changing the finding them that we have.
So any file you can take with whatever data you have, same file for encryption, the encrypted file
later on, pass it as an input filename and create another decrypted finding them to get the output
for it.
So in this way, we have completed the python hacking beginner level code wherein we have covered the
reverse cipher we have covered.
This is a cipher.
Also seeing how to hack with Cesar Saiful.
We have worked on encrypting with the transposition cipher again, decrypting using transposition cipher.
We have seen a program which would run a transposition cipher a number of times with different parameters
on it and get the output with different key and the message parameters.
And finally, how to encrypt or decrypt a particular file in Python.
So with this, we have covered the beginner level, which will give you a start of the start in how
to hack using Python.
So that's it from this session.
Thank you very much.