Hey guys.
Welcome back to another class of our course about Python.
So until now we saw many many interesting things about Python how to use it.
We talked about loops and everything but since we are still talking about loops I decided to create
a small app with you guys where we will practice our for loop together as well as our first statement.
And you guys we'll see what you can do with all this.
And at the same time we're going to create some fun stuff.
So very simple what I decided to create today is that well for example when there are communications
on what's up or let's say telegram or whatever app what's happening is that those communications are
encrypted.
So I decided to do is create a cryptic engine to be able to cripple lets say conversations.
So what we'll do today as they explain we'll do our scripting engine.
So this engine will simply crypt let's say all the words that we'll write down so let's say write down
a word.
So this engine will crypt our word.
So let's start.
So very simple.
What we want to do right now we want to.
Well let me just explain exactly how this will work.
So our scripting engine will equipped each letter by a number.
So let's say for example have a letter a letter B literacy and each letter will have a number or a certain
symbol and our user will write down a sentence where the password and our scripting engine will just
grip everything.
So let's start.
So the first thing I'll ask you guys to do is write down a function so to write down to start the function
we need to write down def and give a name to this function.
So in this case the name of our function will be for example let's say crip crip cryptic encrypted.
That sounds cool.
All right.
So open up our parentheses and what exactly our user will crypt.
So he will crisp the sentence or a word you can write down sentences and write don't wear whatever you
want.
And two points.
All right.
So here starts our encryption.
So we'll have an encryption and for now encryption will put nothing.
So you understand later why we need an encryption.
All right.
So right now how this will work.
It's very simple.
We need to start with our for loop.
So in this case for every element in sentence because once again we need each element it could be for
every letter it could be for every whatever you want.
But in our sentence we'll have well when our user will enter a sentence there will be a letter for it.
So let's say you will he will say let's eat.
He says just hello.
So for every element and hello or for every letter and Hello we are looking to change one letter by
one number.
So let's say for example for every element in our sentence.
So once again you need to use the same words here.
So sentence here and sentence there
what I want to do.
So I want Python to verify if the element is equal to a.
So in this case if the element is a because we will change our letter a first so we'll write down if
element in a.
So what does this mean.
Let me explain.
So the logic is very simple here we have our sentence that the user will enter we want Python to verify
for each element in our sentence.
If this element is in a.
So if there is an A a big eight or small eight in our element we can put them together.
So it doesn't really matter because Python or if there is this letter or this letter in our sentence
then if there is a letter what we want to do we simply want to add our encryption.
So in this case is going to.
Encryption will be equal to encryption plus one.
All right.
So what does this mean.
Our encryption for now is equal to zero what we want to do by writing encryption equals encryption plus
one.
This means we'll add one here and then this case will change our a by 1.
So this is what all this means.
So this is a good way to change our first letter by year well by one because you can see it's very very
well it's very simple in this case let's say.
Translation here it's gonna be way easier for you to understand
all right.
So right now we got everything next thing that we want to want to do the exact same thing for each letter
of the alphabet.
So for the letter B letter C letter D and the other letters.
So how exactly we do this.
Very simple.
We simply copy the if statement right here so we can copy it and we passed it down there.
And instead of the letter A we will use the letter B but it's very important since we are working with
a if statement that is in another if statement.
We'll use the Elif
because once again we're working with a if statement and if statement that is another if statement great.
And not forget change or one by two.
So what you understand from here right there what we have.
So Def scripted sentence so right here for each element in our sentence we will change will will we
ask Python to look for each element in our sentence if our element is equal to a we want to add one
to our element.
So instead of having let's say a want our eight to become one.
So this is what what this means then when this part is done one to verify the exact same thing for the
letter B and then it's going to be if we have a b wanted if we want to change our B by the letter to.
So this is the first part of our or the first part of our translation where our encryption.
So the next thing that we want to do want to do this for each and every letter that we have.
So simply copy our let's say we take our elif statement here and the best in there and instead of writing
it it's going to become C. and instead of two here it's gonna become three.
As you can see it's very easy.
I want to ask you guys to do right now is simply do the exact same thing for all the letters of the
alphabet.
So at the end they should give you something that looks like this as you can see I have all my letters
here and each of my letters is trans.
What each of my letters is replaced by a symbol.
All right.
If in the case that all this is not respected what one might done to return.
Well it's very simple.
We want Python to return translation plus element.
So in this case translate to a translation Translation so is equal to nothing and plus element
will be equal.
And then we return.
Translation
great.
So as you can see right here what we can understand here is that each letter of our alphabet will be
changed by a number so in this case let's say for example the letter A will be changed by one letter
B will be changed by two letter C will be changed by G.
So this is the goal of our operator here.
Right now we want to print exactly so it's very simple.
We want to ask our user to print.
We will ask our user to write down a sentence a sentence or a password or whatever and this password
will be cryptic.
So how do we ask our user to print something very simple.
We'll use our print function and write down our cryptic so the name of our our function here is cryptic
so we write down print will print cryptic but inside our encrypted we want to ask our user to write
down a sentence.
So how exactly we ask.
We ask our user to write down a sentence we will use our input function.
So I don't input and in this case we'll ask our user to write down the sentence will tell him what do
you want to script.
Great.
So here here is our function so you can see we have our function right here that we created.
Our function is named cryptic our function changes letters by numbers or symbols.
And here we ask a python to print our function in which we'll write down we'll ask our user to write
down a sentence.
So if we run our code to see what it looks like and our code ask us What do you want to quit.
So let's say I want a script.
Hello my name is someone as you can see here it is.
It's our encryption we can write down anything we want.
Let's say for example Hello.
I love pizza as you can see all the symbols are not cryptic.
Since we didn't define an encryption for our symbols but if you guys wanted to find encryption for your
symbols well you can do it as well so you can see here we have everything that we ask by thumb to encrypt
is encrypted 2 8 5 b is H.
So if we verify on our code right here h e so 8 5.
All right.
So I hope you guys understand what I'll ask you right now to do to practice everything that we just
saw.
Well you have your equipment encryption so have your encryption.
I think your encryption software right now it's something very basic.
But once again you have it right then what I'll ask your guest to do is try once again just to practice
tried to create an decryption decryption software.
So once again you have your encryption there and you want to decrypt your code.
So let's say you want to decrypt all this.
What you what you just wrote it means hello.
I love pizza so try to do a reverse engineering reverse engineering and try to go from this to this
right here.
So simply recreate another software like this and try to go from this encryption to back to the normal
word to the normal word.
So that's it for this class guys.
Right now you know how everything works.
We created our small project and see all in our next class.