So now the world sees this particular fight scene drive and let us see which by the name.
Substitution cipher Benmore.
Not Levi.
In the same folder, you'll see it and now let us try and execute them or you find it is double is equal
to here.
So again, let us save it and try to run this in an error or this implicit fine.
Let us check this.
What is the error?
Let's see if the key that we have taken is proper and it should not be repeated.
So let us just validate that key first.
So here, the key that we have taken is L.F. w o a ViiV.
Then you have you I s we he and then you have a, b, b, d, c are.
Then you have g, d, q he said.
So as far as we see that is more characters repeating over here.
So let us check what we have passed.
He is what it is.
We have the Michy orbit and when in this particular function that this is what it is, we are passing
the list asdf that's equal to the list.
Start here and let us.
This list is equal to the letter this year that we have created.
And the list as you are sorting it, and this is also something, then we are returning the test which
is equal to that of this test.
OK, so if this is coming us valuable here, then we are giving a system.
Not in that case.
Now what are we supposed to do is we have missed here, if not valid, then I'm going to give an ETA
if it is valid, because this would if it is regarding this, are valid.
So if it is a valid ticket, then we are moving for encryption.
So now if we try to execute this, we get the encrypted message.
Now we would copy down this message here and paste it or substitute that over here.
So let's add it below my message of.
They start here and we will just come into this for the time, let's save this and let us execute one
more mistake we made.
This is not and this is different.
Save it and run it.
So this is all we are decrypting.
It got the same message that we from within.
Right.
So now let us understand the food that we have written here.
First thing is we are importing the paperclip system and random modules and the letters are variable
is set to a string of all the uppercase letters, which is this implicit for a simple substitution cipher
program.
Then we have the main function, which is similar to the main function of cipher program in which we
basically call when the program is run first and it contains variable that stores the messages and immodesty
are used for the program.
Now the keys for a simple substitution cipher are easy to get wrong because it's fairly long and need
to have every letter in the alphabet.
So, for example, it is easy to enter a key that is missing, a key that has the same letter twice,
for example, and then check that if your key is valid function, make sure the keys usable by the encryption
decryption functions so the function exists.
A program with an error message of the key is not valid.
Now in this case, if this particular statement returns false, then the murkiest is contains an invalid
and the program is terminated all over Europe and we are checking whether the mind is still variable,
is said to encrypt or decrypt, and we accordingly, given particular methods, will adhere to the total
value of this particular method would be a string which is encrypted or decrypted message that is stored
in your translated Istria variable.
Now after that, we are copying the value over here, using our copy method on the label so the encrypted
or the decrypted message is printed to the screen and also copied to the clip.
Now after that now next, we will look at how the key is whether this function uses this sort of method
to test whether the key is valid.
So, first of all, we will see understand what is this awfullest material.
Now, the list have a sort of a code that rearranges the list items into numerical order.
And this ability to sort items in the list comes in handy when you have to check whether Doulis contains
the same items, but don't list them in the same order.
So in this particular program, a simple substitution key string value is valid only four times each
time it goes in the symbols set with no duplicate or missing letters.
We can check whether the string value is a valid key by sorting it and checking whether it's equal to
the sorted list or letters.
But we can only list and not strings.
OK, we'll open list of origin of the string values by passing them to the list method.
Then after sorting this list, we can compare the two to see whether or not they are equal.
Now, although later this year is already in the alphabetical order, we will sort it because we will
expand it to contain other characters later.
So hence we are saying string key is passed on to the list method here and the list value written is
stored in the variable named list.
Then the letters constant that we have created this past on again to the list method in the next line,
which is on the list in again all sorted order.
That is again in ABCDE that now after this we are doing here the list in the list.
SDR and the letters list are then sorted in the alphabetical order by calling the sort list method on
them.
Now note that similar to the appendix method, short list also modifies the list in the place and doesn't
have a written value.
So when the list and the letter list SDR values should be the same because he lists SDR will simply
be correct later this year with an order scramble.
So when we check whether the values of Aschiana letters this year are equal, the values are then after
checking it, they are basically written values, then passed on to the matter there.
So over here, in case this returns true if they are equal and have no duplicates, but if your list
is there and that does, it still doesn't match.
The key is invalid and it is written for what's now coming to the wrapper function.
The encryption or the decryption code in the program are almost identical.
If you can see here when you have two similar pieces of code, it's best to put them into a function
and call it twice rather than enter the court.
So not only does this save your time, but also more importantly, it avoids introducing books like
Copying and.
So it's also advantageous because that is very small every quarter and you have to only fix one book
at a time instead of looking at for multiple places.
So this rappel function helps you avoid having to enter duplicate code by wrapping the code of another
function and returning the value.
The wrapped function with often the wrapper function makes a slight change to the arguments of the return
values of the wrapper function.
Otherwise, there would be no need for wrapping because you could just call the function directly.