So now coming to getting the hacked message and using over here the hack transposition cipher function,
we start with a couple of print statements there.
That is, we are seeing print hacking, then printing press control on windows or accountability on
Mac OS and Linux to quit at any time after this.
Now, because the program may try many keys and the program displays a message telling the user that
the hacking has started and that it might take a moment to finish the process.
So the print command over here is the user to losing on Windows of the old Linux or OS to exit the program
at any point.
You can actually press this to exit any running Python program on the particular given operating system.
And after that, the next couple of lines tells the program which key to loop through by specifying
the range of possibilities for the transposition cipher.
So over here, we run this for loop after that, saying for a start in the range of one till the length
of the messages we are saying print drying the key and the number of the key that it is trying.
So the possible keys for the transposition cipher range between one and the length of the message.
OK, and the for loop on this particular line, there is the hacking part of the function which with
each of these particular given keys.
So it uses the string interpolation to print the key currently being tested, using the string interpolation
to provide a feedback back to the user.
So using the message that this or using the function that is Demo 16 dot decrypt the message which is
there in our Demo 16 Lopevi program that we have already written, it gets the decrypted output from
the current key being tested and stores that particular value in the variable that is decrypted next
year.
And the decrypted output in the particular variable encrypted text is still will be English.
Only of the current equals you.
Otherwise it would appear as the garbage to.
So then the program passes that particular string or that is decrypted next year into his English check
function, which is there in our English, not by OK.
And then it is part of the decrypted text Asgeir the key use and the instructions for the user, that
is, it asks for a blank line put in the possible encryption hack, but is the key again a blank line
and then asked for the response from the user by asking you to press the if it is done now does because
the chicken is English check method written through and move the execution to the next line.
It doesn't mean that the program has found the correct.
It could be a false positive, meaning that the program dictated some text as English that is actually
a garbage did so to make sure that it reveals the text so the user can confirm that the text isn't in
English, it uses that decrypt.
The text is still calling for free to print out the first 50 characters of the day, and then the program
pauses after the particular line and ask for or wait for the user to enter the or anything else.
And then stores that input as a string in the given responsibility, not understanding the strip string
method.
A program gives a user specific instruction, but the user doesn't follow them.
Exactly.
And error results.
And when of a particular program prompts the user to enter the form the hacked message, it means that
the program won't accept any input other than the end of the user and does an extra space or character
along with the the program won't accept.
So let us look at how to use this strip string method to make the program accept other inputs as long
as they are similar enough to be so.
The strip string method returns a version of the string with any whitespace characters at the beginning
and end of the string stripped out now out.
These characters are the space characters type characters and then you learn that.
So for this we would enter some following text in the interactive shell to see how this basically works.
So if we go over here and if we write down here a certain space right down, hello, and then we use
the strip, still, we get only the text that is hello.
Or if we write down using, say, some special characters, then.
Dot strip.
Still, it is coming the same way, or if we try to give space before
OK and say here dot strip, not in between the words, the space will be counted, but before and after
that would be removed.
In the given examples over here, the strip method remove the space characters at the beginning, at
the end of any given strength.
OK, so if a particular string includes space at the beginning or at the end of the string, the metal
remove them from the site but doesn't remove any space between other characters.
The strip method can also have a string argument postulate that is a method to remove characters other
than white space from the beginning and the end of the string.
Not to see an example for this, say we give over here on the example C write down any characters or
let's write on just one character in this case.
See BP right down here.
Hello, BP.
OK, dot strip.
And we give the character piece so it removes P from every bit.
OK, or suppose we have used, say, a baby everywhere.
This is our text we use here.
Dot strip say a bit.
So it removes a bit and gives us the given string.
OK, like that we can give your example.
OK so if you pass a string arguments the A or a B remove this characters when they occur at the beginning
of the end of the string.
Similarly, but that will give given strip function doesn't remove characters embedded in the middle
of the string.
So let us see.
Applying the strip string method over in our given program here.
Now let's return to this old school and see how to apply this drop in our given program.
So after this, if we go below, OK, we are having this condition over here.
Now, in this we are using the if the response starts stripped, talk about what starts with B now,
if the condition for the statement or simply responds is equal to capitally, the user would have to
enter capitally.
Exactly.
And nothing else to end the program, for example, of the user interface Molde or some spaces capitally
or say the capitalised on the condition would be false and the program would continue checking other
PS instead of returning the act.
So to avoid this issue, the string and the response remove the white space from the start and the end
of the string with the to strip.
Then the string that the user response strip evaluates to has the method called on whether the user
enters mouldy or capitally.
The string return from the above will always be capitalized test capitally, so adding the flexibility
in the type of the input the program can accept and make it easier to, you know, to make the program
accept user input.
That starts with the but it is Fullwood we can use.
This starts to check only the, for example, of the user input space.
The other response.
Then the white space would be stripped and the string done would be passed to upper.
After Apple capitalizes the whole string into capital, the string is then passed on to starts with,
which returns the true because the string that starts with the substring B.
Now, if the user indicates that the decrypted string is correct, the function we are to have transposition,
Asscher will return.
The decrypted text is still not failing to have the message, for example, of the first line of default
loop that began over here in that is for Keirstead in the range.
If that particular loop has begin and the program execution reaches this point, it means the program
has never reached the written statement, which would happen if the correctly decrypted text was never
found for any of the keys that would break.
So in that case, it returns non-value to indicate the hacking has been OK.
So after this, we come to the last part overfill.
That is, we are checking OK, although the main function of this program was run by itself rather than
being imported by another program using its high transposition SDR function.
So remember that the name variable is said by Python and the main function will be will not we call
it your current file that this transposition example is important as the module?
OK, so with this, we have understood how the particular program has been created.
How does it execute and what is the output that we are getting from the executed program?