Welcome to the next session in our Python hacking code that is hacking the seasonal cipher, using the
brute force.
Now we can hack this is a cipher by using a another technique, which is called brute force.
A brute force attack tries every possible decryption key for a particular cipher.
Nothing can stop a cryptanalysis from getting one, decrypting the ciphertext with that key, looking
at the output.
And then we want to the next key, if they didn't find the secret message now because the brute force
technique is so effective against Caesar Saiful, you shouldn't actually use a Caesar cipher to encrypt
secret information.
Now coming to a new file, which we will be creating for this particular demonstration.
So let us go to our potential and create a new file here.
And first thing is, we will type our hacker code over here for Caesar Saiful.
So now you let us create first same message SDR and we'll give here the text in a decrypted format,
OK?
So we'll use a single code and we'll give you some text in a decrypted format.
See six.
She said exclamation g six.
Now this is all in encrypted format that we are typing just to see the output that we get.
Similarly, we would use your symbols as and we'll save you all the capital letters cost
X, Y, Z, similarly will store everything in this mall.
OK, and after that, we will store also the new Marika's a space exclamation mark, a question mark
or dot everything in the symbol that we have written, the symbol Asgeir in the capital, because we
want to make sure that this is what we basically we are creating as a constant, which will not have
the values changed frequently.
OK, then we will look through the every possible key.
So over here we will run for loop things for key estie are in.
Range rockets will give the length of symbols start over here and will open the for loop and inside
of this for loop, we will basically set a variable to blankest drawstring so that the previous iteration
values for the particular text is clear.
So we'll see.
Translated SDR is equal to like OK now.
The Restoril down below would be same as almost same as I will see the Saiful program that we had done
in the last session.
So over here, we look to each symbol in the particular message.
So for that, we will run for loop again, say for a swim in.
Message SDR, open the loop, then inside this, we check if the value of X, y, m in.
Symbols are OK, then you see one more variable symbol index or this y m.
Index, which is equal to we see Symbolistic, Dot, find the value of X, Y, and then we say the.
Translated, that is equal to our SVM index, minus the value of now here we would be taking the value
for ATSDR and then we will handle the wrap around here below.
We would say if our C translated into X, if it is less than zero colon, then we c c translated it
is equal to translated into X plus the length of.
Symbolistic.
OK, after that, we would open the decryption module, so we'll go one level back and he'll receive
the translated SDR is equal to what is the initial value when translated SDR, plus adding that the
value of SYMBOLISTIC index of translated ideas like that is the index key that we would be taking for
adding one one value in the translated queue.
Now after this we would go for the upper F condition is so we'll go here for LS column and here we would
write down the value of.
Translated SDR is equal to.
Translated Astar Plus, I am OK, and now for display every possible description text, let's go one
level back and we'll come for the melody for and over here we will give up and come on see Saiki.
Value give you a little hash, then we give you a percent is golden.
Bosomed is the single quotation marks we would print the value of yesteryear and the value of.
Translated SDM, OK, now let us see if this would save it in Python Hacking Beginner.
Now let's give you the demo age, OK?
And save it now to run this.
Will go for unmodern and over here at one point of time, you would see.
We are getting this particular fixed in a normal English code because we have given this as the key
core thing where we had decrypted that using the particular key, you here will also find out what good
we have used.
OK, now one important thing over here, what mistake we we must have made is over here inside the message.
Let us check the encrypted message that we have written.
It is G.V. then we have six juvy, then it is six GZ in here, or we don't have this exclamation mark
also.
Whereas after 60 we have you say F Arpit, then five or seven and we have G now here we have this capitals
that are that is six to six and this also is not so.
Now let us save this and let's try to run the Modu.
So now if you check out at number 13, we get the value.
This is a secret message.
OK, again, here, let us just check once.
OK, Chris, let us open our scissors for program, and here we have written.
This is my secret message.
We want to encrypted this.
So now let us check the output for this program.
OK, now this is the encryption key.
So now let's copy this.
Let's close this.
And here let's cooperate on the same encrypted text, OK?
And now let's try to run the module.
Now let's check on number 13.
OK, some mistake again.
And that mistake is over here.
It does not.
And then it is an.
OK, let's save this and run it again now.
Yes, so now you can find out what is the original message and which key was used to encrypt this particular
message.
OK, now let us understand the code that we have written.
OK, now, for years, we have seen how the output is coming.
OK, so we are getting the output in a decrypted format on the key today, which is coming in a plain
English text.
So now we can know that the original encryption key must have been 30.
Right.
So with this now, let us understand the code that we have written.
So let's go back to the code here.
OK.
Now, here, the program we are creating, this message, which is basically storing the ciphertext,
was a string in the program that is trying to decrypt.
Similarly, the next is we are having the symbols, which is a constant variable containing every character
that decipher can encrypt.
So it will be from capitals, smores, even the numbers.
OK, now this value in the symbols of a state that we have given needs to be the same as the value for
the symbol as you have used in the C the cipher program.
Otherwise you will not get the hacker program, will not work properly.
Even know that with the space between zero, exclamation mark has to be there, as you have written
in the same.
So see the cipher program.
Right now let's come to the next part where we go for looping with the range function.
So over here we basically doesn't want to string value, but instead we attribute the return value from
the call to the range function.
So the range function here takes integer arguments and returns a value of the range data.
Right now, the range values can be used in four loops to loop of specific number of times, according
to the integer you give in the function.
Now let us try some example of this range in the interactive.
So let's go here and we will write down here, for example, for I1 in range C for Colon.
And here we give C print in bracket C fighting, hacking.
OK, so four times we're getting the string python hacking print.
So you'll be for a loop the loop for four times because we have the integer four in the reach.
So more specifically the range value return from the range function called reset the loop or the four
loops variable to integers from zero to the argument that is passed in the range.
So for example, here we are having from zero to four.
OK, so more specifically, if you want to know how the arguments are passed onto the program, that
you can try it out over here.
This is for Ivan in range.
We give you say seven.
OK, and now we try to put it in brackets, the value of Ivan.
OK, now let's see how this it is going from zero six because we are giving their range in bracket seven.
Right.
So over here because that's the variable even to the value from zero, but not including seven, which
is similar to what we have in the Olelbis.