Now, in this session, we could be looking at the simple substitution cipher now in the last session
we have learned that the Afine Saiful has about a thousand possibilities, but that computers can still
brute force through all of them easily.
So we need a cipher that has so many possibilities that no computer can brute force through them all.
So the simple substitution cipher is one such cipher that is effectively invulnerable to a brute force
attack because it has enormous number of possible keys.
Even if your computer could try a trillion keys every second, it would still take 12 million years
for it to try every one.
So in this particular session, we would write a program to implement a simple substitution cipher and
learn some useful python functions and string methods as well.
So topics covered in this particular session will be the smallest matter.
Getting rid of the duplicate characters from a string of functions and using his opponent is lower string
functions or methods.
So moving on to how a simple substitution cipher.
Now, to understand this, let us go to a blank Excel now to implement the simple substitution cipher.
We basically choose a random letter to encrypt each letter of the alphabet and using each letter only
once.
Now the key for a simple substitution cipher is always a string of twenty six letters of the alphabet
in any random order.
And if you look at it, there are basically four zero three two nine one four six one one twenty six
six zero five six thirty five five eight for so many number of different keys available.
Now there are so many different possible key ordering for a simple substitution, and this is a lot
more keys.
So more importantly, this number is so large that it is impossible to brute forces.
Now, let us try using a simple substitution cipher with paper and a pencil like we would be doing it
on Excel, for example.
They will encrypt the message said by hacking, for example.
Now here we would be using certain keys.
Now we would write down our alphabet and the corresponding keys under each alphabet.
So say, for example, we would write down here all the alphabet, the capital alphabet.
So A.B., let's take it from this.
A, b, c, d, e, f, g.
H i j k l m n o p q oreste.
W, X, Y, Z and.
Let's make it small.
For example.
For that, it is just viewed.
So all together, we don't need to scroll.
And below this, we would be writing down the keys and I'll say we would be using your keys as we G,
that B, G and F to be L i d m x said w w then Q. You see why he h s o.
So every character again used just once.
So if you see hear this, every single character is having another substituted character for it, and
these characters are also not repeating in it.
So in that case, only if you see this same is substituted by those same characters.
Viterbi same.
But others are totally different now.
This combination of random character generations could be a very large number.
So in part, in this particular case, not to encrypt the message, we will find the plaintext from
the top root and we substitute the letter in the bottom.
So if we just write down it over here that we have that this post is B, so B, we'll take it.
The Intrepid will be saved by then w then we have like so very having s the B is having C, H is having
a substitution of E, always having substitution of B and end is having a substitution of X, then we
are having hacking.
So H is having a substitution of E A's having off.
We then C is having a Z, he is having a substitution of pi.
Similarly N is X and G is F, so this is what would be OK and cryptic text would look like, like.
So not to decrypt the encrypted message you will find the letter in the cipher, text in the bottom
row and you would replace it with the corresponding letter in the top.
So like for example your W which will be replaced by B, so on and so forth.
So unlike a Caesar cipher in which the bottom row shifts but remains in the alphabetical order in a
simple substitution cipher, bottom row is completely scrambled.
So this results in far more possible, which is a huge advantage of using a simple substitution cipher.
And now the disadvantage is that the key is a twenty six characters long and more difficult to memorize.
You may need to write down the key somewhere, but if you do so, make sure that no one is ever reset.
OK, now let's come to a simple substitution cipher code.
OK, we'll go back to let's close this.
OK, now another potential.
We would create a new file and we would enter the code in this file at the top and then save it and
execute it again.
We will place this in the same folder where we have the paperclip module.