Welcome to the next session in our Python Hacking Advanced Course, which is basically about hacking
the videos now, as we have discussed in the earlier session, that are two methods which exist to have
the Virginia Saiful one method uses the brute force dictionary attack to try every word in the dictionary
as a beginner, which works only if the key is in an English or something like a disk or an oven or
something like that.
The second or the more sophisticated method which was used in the 19th century.
Mathematician Jarvis Babbage walks even when the key is a new random group of letters.
It may be any letters from A to Z.
Now, in this session, we would be writing down programs to hack the Virginia cipher using both methods.
So the topics which would be covered in this would be or dictionary attacks, your kazatsky examination,
calculating your factors, said data type and the functions extend this matter and item to store the
product function.
So let us start by knowing first how to use a dictionary attack to brute force.
The beginning of Saiful.
Now the first.
We will be using the dictionary attack to have the Saiful.
Now the dictionary file which we have used earlier that is a dictionary to define, has approximately
somewhere around forty six thousand English votes and it takes less than five minutes for any computer
to run those.
All the predictions for a particular message the size of a long paragraph, which means that if an English
word is used to encrypt a Virginia ciphertext, then the ciphertext is one that it will do a dictionary
attack.
So let's look at the source code for the program that uses the dictionary attack to hack your Virginia
cipher.
So we would be creating a new file and in that, using the new file editor, we will be entering some
code in the file up, saved by a particular name.
And we sure that you have to place your check English file for them all, which we have also created
by booklet files all in the same directories variable will receive the current file.
So first of all, let us go to find new find and create your file for the happy demo.
Now, before that, let us go to our folder, which we have saved all the documents to now.
So if you look at this, we have the dictionary file available here.
We have over English file is not there.
We need to copy down that.
We have the file, which we have created and obviously of original site for demo file, which we have
used one file that is missing audio Desertec English file, which we need to create.
Just webpage on that.
OK, so let us do that first.
So we have this check, which we need to import.
We need to import Saiful demo and the.
So let's go here.
And first of all, let's start with the import statement.
That's first check English
next.
We would be importing the beginning for demo, so let us hope you don't define them directly so that
we avoid spelling mistakes and obviously other.
And once we have done this, we will start by defining our main method here, and he'll be able to define
a particular ciphertext.
See, for example, ciphertext SDR is equal to some order, which we would be writing down later.
Then we would be taking another Sehat message SDR.
And in this, we would be calling a function that we will create below.
That is for your beginner dictionary and frequency and we would be passingly ciphertext Astana's.
But I would.
And once we have passed that, we will check if your text message SDR is not equal.
Do not, then you are going to say print, say, copying text message to Clybourn and then you put into
the value of.
Hacked message is off, then we see Paperclip got copied and hacked message are after that we go for
the fence.
But that is, if it is equal, do none, then we are going to put into the same field to hack encryption.
That would be the statement in our block.
And now coming to the definition of the function that we have defined in the mail that this will define
here.
See hack in our dictionary function, which is going to obviously be ciphertext esterase.
But and in this we are going to open.
So we will say if one is equal to say, open the file, that this dictionary dot the state, which is
that in the same folder will be able to receive the current fight.
Then we say votes one is equal to F for one dot three lines, after which we say if one dot.
So we open the file, we read everything from that sorted in votes and then we close different ones.
The file is closed, we run a loop that is to one in your lines.
And over here we would be creating we open up this file and we take your vote.
One is equal to save or one split.
That is, remove the new line at the end of it and then we take C decrypted text is equal to now.
Here we would be calling the decrypt message function off of the beginning of Saiful.
So let us copy it on the beginning side for the here and in this we are having the function that this
decrypt message we had given.
Then let us just try to open up the file, which is another five for demo and the function name over
here we have given is decrypt message.
So we will take that same material and the parameters to Automotive One and Saiful next SD.