Now, let's see another option in all of I forget, that is a definition which is encrypted messages
to decrypt messages.
So now, because the decryption and encryption code is mostly the same, will create to wrapper functions
that this one is able to encrypt.
Messages still function.
Another is over.
Decrypt messages and for the function that is of a translated message which we are going to use or which
will hold the actual code to encrypt.
So over here we are just calling that particular method or call it a method transfer.
Was it instead understanding the value which has been returned by the particular method?
So the translated messages still function versus the encrypted or decrypted string one character at
a time and the list in translated are stored these characters so they can be joined when the string
building is done.
So if we come to the translated messages, start them moment we have here the blank string and the string
Asgeir, which is we are converting it to the uppercase value.
So keep in mind that Evgenia for this just this is a cipher, except a different key is used depending
on the position of the letter in the message.
So the key IDEX variable which keeps track of which suppy to use, starts at zero by default because
the letter used to encrypt decrypt the first character of the messages steer the index zettl.
So the program assumes that the key is in all uppercase letters to make sure the key is valid.
So we call the function there and the rest of the code.
In the translated message, Asgeir is similar to your Caesar cipher.
So we are sitting here for a while and the message is still voted.
No one is equal to the letter tested or to find and convert it to Apple check.
If no one is not equal to one, then you check.
If it is equal to encrypt, then find it and appended to the given letters.
Similarly, if it is decrypt, subtract the value from the letter Oresteia and at the end then we are
seeing it do more and add value to the letter.
So after the for loop it sets the characters in the message to the variable SVM that the symbol on each
iteration of the loop and it finds the index of the uppercase version of Cimolino letters now, which
is how we translate a letter into one number.
So if no one isn't set to minus one, the uppercase symbol was found in the letters.
This still meaning that symbol is a particular letter and the key variable keeps track of which subcu
to use.
And the is always what Yawkey of the index of evaluates to.
So of course this is just a single letter string.
We need to find this letters index in the letters as to how to convert this up to an individual.
And this individual is then added if encrypted encrypting in symbols number or subtracted is grappling
with this enormous number.
And in the seas, I reject whether the new value of the number was less than zero, in which case we
added then the length of letters is still to it, or whether the new value of number one was the length
of letters is still greater in which we subtracted the value from it.
So these check handles the wraparound cases.
However, there is a simpler way to handle both of these cases.
If we more the integer stored in the number one by the length of the letter this year, we can accomplish
the same calculation in a single line of code.
Hence we have done this over here saying no more is equal to length of letters this year.
For example, see if numbers minus eight we would want to add twenty six.
That is the length of the start to get B and that can be expressed as minus eight modulo twenty six
which evaluates to eighty or if numbers thirty one we would want to subtract twenty six to get five
and thirty one modulo twenty six evaluates to five new modular arithmetic hander's voted up or down
cases.
The encrypted order, the decrypted character exist in the letters as the index of number.
However, if we want the encrypted or the decrypted characters case to match the original case of symbol,
hence we are checking over here.
If symbol that is converted to uppercase and appended if it is in law, then converted to lowercase
and then.
So if the symbol is in an uppercase, then if the condition is true, it upends the letters of the characters
at letters index number to the translated Asgeir because all the characters are already in uppercase.
However, if the symbolism, the lowercase letter, the condition is true instead in the next line it
up in the lowercase form of the letters at the index number two translated is.
So this is how the encrypted all the decrypted message match the original message, now that we have
translated this email, we want to ensure that on the next iteration of the loop, we use the next subject.
Hence, we increment the key idea by one in the next line over here thinking X plus is equal to one
click here.
If the key idea is equal to the left of is make it again zero.
So how about if we vote on the last supporting the give X then the key.
All the GST are the X would be equal to the length of the USDA, hence this check condition and we the
it back to zero if that's the case, so that the key to the index of X points back to the first subcu.
Now after this, if we see here, the indentation indicates that the statement is spelled with the if
statement which just started in the for loop after something no one is equal to let Orestiada fine.
So here the code executes if the symbol was not found in the letters.
Now this happens if symbolism no other punctuation mark like say a number, anything like six, seven
something or a punctuation say like a question mark or something like that.
So in that case, it upends the unmodified symbol directly to the translator SDR variable.
So now that we are done building a string and translated Asgeir, we call the joint letter here on the
blank string.
So this line makes the functions work on the whole encrypted order, decrypted message when the function
is called.
Hence after this we just see the lines that cause the main function of the program was run by itself
rather than by being imported by another program that wants to use its encrypt message or decrypt messages
to functions.
So with this, we have understood how the particular Virginia cipher demo executes and what is the core
meaning that we have already written.
So let's continue with the next part or the next session in this advanced course.
That is our frequency analysis in this frequency analysis.
You will learn how to determine the frequency of each English letter in a particular text.
You will then compare this frequency to the frequencies of your ciphertext to get information about
the original plaintext, which will help you break the encryption.