1 00:00:00,560 --> 00:00:01,040 Hey guys. 2 00:00:01,050 --> 00:00:05,460 Welcome back to another class of our course about Python. 3 00:00:05,480 --> 00:00:10,350 So until now we saw many many interesting things about Python how to use it. 4 00:00:10,410 --> 00:00:16,590 We talked about loops and everything but since we are still talking about loops I decided to create 5 00:00:17,220 --> 00:00:24,070 a small app with you guys where we will practice our for loop together as well as our first statement. 6 00:00:24,150 --> 00:00:28,320 And you guys we'll see what you can do with all this. 7 00:00:28,560 --> 00:00:30,750 And at the same time we're going to create some fun stuff. 8 00:00:31,230 --> 00:00:37,470 So very simple what I decided to create today is that well for example when there are communications 9 00:00:37,530 --> 00:00:42,810 on what's up or let's say telegram or whatever app what's happening is that those communications are 10 00:00:42,810 --> 00:00:43,460 encrypted. 11 00:00:43,590 --> 00:00:52,170 So I decided to do is create a cryptic engine to be able to cripple lets say conversations. 12 00:00:52,170 --> 00:00:56,580 So what we'll do today as they explain we'll do our scripting engine. 13 00:00:56,580 --> 00:01:01,650 So this engine will simply crypt let's say all the words that we'll write down so let's say write down 14 00:01:01,680 --> 00:01:02,490 a word. 15 00:01:02,490 --> 00:01:04,620 So this engine will crypt our word. 16 00:01:06,030 --> 00:01:07,230 So let's start. 17 00:01:07,830 --> 00:01:09,250 So very simple. 18 00:01:09,360 --> 00:01:11,370 What we want to do right now we want to. 19 00:01:11,400 --> 00:01:14,540 Well let me just explain exactly how this will work. 20 00:01:14,550 --> 00:01:19,920 So our scripting engine will equipped each letter by a number. 21 00:01:19,950 --> 00:01:25,770 So let's say for example have a letter a letter B literacy and each letter will have a number or a certain 22 00:01:25,860 --> 00:01:32,110 symbol and our user will write down a sentence where the password and our scripting engine will just 23 00:01:32,620 --> 00:01:34,300 grip everything. 24 00:01:34,300 --> 00:01:36,020 So let's start. 25 00:01:36,040 --> 00:01:41,050 So the first thing I'll ask you guys to do is write down a function so to write down to start the function 26 00:01:41,110 --> 00:01:45,460 we need to write down def and give a name to this function. 27 00:01:45,460 --> 00:01:52,790 So in this case the name of our function will be for example let's say crip crip cryptic encrypted. 28 00:01:53,050 --> 00:01:53,730 That sounds cool. 29 00:01:54,370 --> 00:01:54,580 All right. 30 00:01:54,610 --> 00:01:59,240 So open up our parentheses and what exactly our user will crypt. 31 00:01:59,290 --> 00:02:04,210 So he will crisp the sentence or a word you can write down sentences and write don't wear whatever you 32 00:02:04,210 --> 00:02:05,590 want. 33 00:02:05,590 --> 00:02:06,610 And two points. 34 00:02:06,820 --> 00:02:07,730 All right. 35 00:02:07,900 --> 00:02:11,340 So here starts our encryption. 36 00:02:12,040 --> 00:02:17,790 So we'll have an encryption and for now encryption will put nothing. 37 00:02:18,280 --> 00:02:23,440 So you understand later why we need an encryption. 38 00:02:23,470 --> 00:02:23,710 All right. 39 00:02:24,280 --> 00:02:26,020 So right now how this will work. 40 00:02:26,110 --> 00:02:27,790 It's very simple. 41 00:02:27,790 --> 00:02:30,400 We need to start with our for loop. 42 00:02:30,420 --> 00:02:40,060 So in this case for every element in sentence because once again we need each element it could be for 43 00:02:40,120 --> 00:02:42,340 every letter it could be for every whatever you want. 44 00:02:42,430 --> 00:02:48,610 But in our sentence we'll have well when our user will enter a sentence there will be a letter for it. 45 00:02:48,640 --> 00:02:51,230 So let's say you will he will say let's eat. 46 00:02:51,270 --> 00:02:52,280 He says just hello. 47 00:02:52,870 --> 00:02:59,860 So for every element and hello or for every letter and Hello we are looking to change one letter by 48 00:02:59,860 --> 00:03:00,840 one number. 49 00:03:01,510 --> 00:03:07,920 So let's say for example for every element in our sentence. 50 00:03:10,360 --> 00:03:12,870 So once again you need to use the same words here. 51 00:03:12,880 --> 00:03:14,260 So sentence here and sentence there 52 00:03:17,940 --> 00:03:18,470 what I want to do. 53 00:03:18,990 --> 00:03:24,600 So I want Python to verify if the element is equal to a. 54 00:03:24,870 --> 00:03:33,370 So in this case if the element is a because we will change our letter a first so we'll write down if 55 00:03:37,110 --> 00:03:40,670 element in a. 56 00:03:41,850 --> 00:03:44,060 So what does this mean. 57 00:03:44,070 --> 00:03:44,650 Let me explain. 58 00:03:45,030 --> 00:03:53,990 So the logic is very simple here we have our sentence that the user will enter we want Python to verify 59 00:03:55,210 --> 00:03:57,040 for each element in our sentence. 60 00:03:57,040 --> 00:03:59,810 If this element is in a. 61 00:03:59,830 --> 00:04:04,820 So if there is an A a big eight or small eight in our element we can put them together. 62 00:04:04,960 --> 00:04:10,030 So it doesn't really matter because Python or if there is this letter or this letter in our sentence 63 00:04:11,070 --> 00:04:21,180 then if there is a letter what we want to do we simply want to add our encryption. 64 00:04:21,180 --> 00:04:22,130 So in this case is going to. 65 00:04:22,150 --> 00:04:31,600 Encryption will be equal to encryption plus one. 66 00:04:31,640 --> 00:04:31,850 All right. 67 00:04:31,850 --> 00:04:32,690 So what does this mean. 68 00:04:33,470 --> 00:04:39,370 Our encryption for now is equal to zero what we want to do by writing encryption equals encryption plus 69 00:04:39,370 --> 00:04:39,830 one. 70 00:04:39,970 --> 00:04:45,870 This means we'll add one here and then this case will change our a by 1. 71 00:04:45,880 --> 00:04:48,920 So this is what all this means. 72 00:04:48,940 --> 00:04:56,990 So this is a good way to change our first letter by year well by one because you can see it's very very 73 00:04:57,050 --> 00:05:02,090 well it's very simple in this case let's say. 74 00:05:02,230 --> 00:05:06,940 Translation here it's gonna be way easier for you to understand 75 00:05:15,260 --> 00:05:15,700 all right. 76 00:05:15,700 --> 00:05:22,320 So right now we got everything next thing that we want to want to do the exact same thing for each letter 77 00:05:22,830 --> 00:05:23,910 of the alphabet. 78 00:05:23,940 --> 00:05:28,860 So for the letter B letter C letter D and the other letters. 79 00:05:28,860 --> 00:05:30,220 So how exactly we do this. 80 00:05:30,240 --> 00:05:31,100 Very simple. 81 00:05:31,170 --> 00:05:37,900 We simply copy the if statement right here so we can copy it and we passed it down there. 82 00:05:39,070 --> 00:05:46,510 And instead of the letter A we will use the letter B but it's very important since we are working with 83 00:05:46,600 --> 00:05:49,840 a if statement that is in another if statement. 84 00:05:49,910 --> 00:05:50,950 We'll use the Elif 85 00:05:54,400 --> 00:06:02,590 because once again we're working with a if statement and if statement that is another if statement great. 86 00:06:02,920 --> 00:06:06,660 And not forget change or one by two. 87 00:06:06,670 --> 00:06:10,990 So what you understand from here right there what we have. 88 00:06:10,990 --> 00:06:19,350 So Def scripted sentence so right here for each element in our sentence we will change will will we 89 00:06:19,350 --> 00:06:27,480 ask Python to look for each element in our sentence if our element is equal to a we want to add one 90 00:06:27,480 --> 00:06:28,150 to our element. 91 00:06:28,150 --> 00:06:34,340 So instead of having let's say a want our eight to become one. 92 00:06:34,350 --> 00:06:41,250 So this is what what this means then when this part is done one to verify the exact same thing for the 93 00:06:41,250 --> 00:06:52,460 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. 94 00:06:52,510 --> 00:07:01,360 So this is the first part of our or the first part of our translation where our encryption. 95 00:07:01,420 --> 00:07:05,860 So the next thing that we want to do want to do this for each and every letter that we have. 96 00:07:06,190 --> 00:07:15,100 So simply copy our let's say we take our elif statement here and the best in there and instead of writing 97 00:07:15,210 --> 00:07:21,810 it it's going to become C. and instead of two here it's gonna become three. 98 00:07:22,380 --> 00:07:23,500 As you can see it's very easy. 99 00:07:23,810 --> 00:07:30,340 I want to ask you guys to do right now is simply do the exact same thing for all the letters of the 100 00:07:30,340 --> 00:07:31,940 alphabet. 101 00:07:32,020 --> 00:07:36,760 So at the end they should give you something that looks like this as you can see I have all my letters 102 00:07:36,760 --> 00:07:41,350 here and each of my letters is trans. 103 00:07:41,360 --> 00:07:45,760 What each of my letters is replaced by a symbol. 104 00:07:45,850 --> 00:07:47,300 All right. 105 00:07:47,800 --> 00:07:52,810 If in the case that all this is not respected what one might done to return. 106 00:07:52,810 --> 00:07:55,480 Well it's very simple. 107 00:07:55,480 --> 00:07:58,510 We want Python to return translation plus element. 108 00:07:59,080 --> 00:08:07,480 So in this case translate to a translation Translation so is equal to nothing and plus element 109 00:08:11,350 --> 00:08:12,060 will be equal. 110 00:08:27,640 --> 00:08:31,210 And then we return. 111 00:08:31,210 --> 00:08:31,750 Translation 112 00:08:37,790 --> 00:08:38,550 great. 113 00:08:38,600 --> 00:08:45,710 So as you can see right here what we can understand here is that each letter of our alphabet will be 114 00:08:45,710 --> 00:08:50,450 changed by a number so in this case let's say for example the letter A will be changed by one letter 115 00:08:50,450 --> 00:08:55,080 B will be changed by two letter C will be changed by G. 116 00:08:55,500 --> 00:08:58,890 So this is the goal of our operator here. 117 00:08:58,890 --> 00:09:01,740 Right now we want to print exactly so it's very simple. 118 00:09:01,740 --> 00:09:04,550 We want to ask our user to print. 119 00:09:04,560 --> 00:09:11,130 We will ask our user to write down a sentence a sentence or a password or whatever and this password 120 00:09:11,220 --> 00:09:12,000 will be cryptic. 121 00:09:13,200 --> 00:09:16,440 So how do we ask our user to print something very simple. 122 00:09:16,440 --> 00:09:26,080 We'll use our print function and write down our cryptic so the name of our our function here is cryptic 123 00:09:27,090 --> 00:09:35,970 so we write down print will print cryptic but inside our encrypted we want to ask our user to write 124 00:09:35,970 --> 00:09:37,290 down a sentence. 125 00:09:37,290 --> 00:09:38,500 So how exactly we ask. 126 00:09:38,700 --> 00:09:43,800 We ask our user to write down a sentence we will use our input function. 127 00:09:44,220 --> 00:09:52,260 So I don't input and in this case we'll ask our user to write down the sentence will tell him what do 128 00:09:52,560 --> 00:09:55,890 you want to script. 129 00:09:56,300 --> 00:09:58,410 Great. 130 00:09:58,710 --> 00:10:04,380 So here here is our function so you can see we have our function right here that we created. 131 00:10:04,380 --> 00:10:10,740 Our function is named cryptic our function changes letters by numbers or symbols. 132 00:10:10,920 --> 00:10:18,270 And here we ask a python to print our function in which we'll write down we'll ask our user to write 133 00:10:18,270 --> 00:10:19,930 down a sentence. 134 00:10:20,070 --> 00:10:26,200 So if we run our code to see what it looks like and our code ask us What do you want to quit. 135 00:10:26,200 --> 00:10:27,940 So let's say I want a script. 136 00:10:28,150 --> 00:10:38,040 Hello my name is someone as you can see here it is. 137 00:10:38,200 --> 00:10:41,980 It's our encryption we can write down anything we want. 138 00:10:42,040 --> 00:10:47,090 Let's say for example Hello. 139 00:10:47,710 --> 00:10:53,700 I love pizza as you can see all the symbols are not cryptic. 140 00:10:53,700 --> 00:10:59,440 Since we didn't define an encryption for our symbols but if you guys wanted to find encryption for your 141 00:10:59,440 --> 00:11:05,530 symbols well you can do it as well so you can see here we have everything that we ask by thumb to encrypt 142 00:11:06,310 --> 00:11:09,790 is encrypted 2 8 5 b is H. 143 00:11:09,880 --> 00:11:16,820 So if we verify on our code right here h e so 8 5. 144 00:11:16,900 --> 00:11:17,280 All right. 145 00:11:17,950 --> 00:11:22,690 So I hope you guys understand what I'll ask you right now to do to practice everything that we just 146 00:11:22,690 --> 00:11:23,080 saw. 147 00:11:23,230 --> 00:11:27,060 Well you have your equipment encryption so have your encryption. 148 00:11:27,130 --> 00:11:32,470 I think your encryption software right now it's something very basic. 149 00:11:32,470 --> 00:11:37,900 But once again you have it right then what I'll ask your guest to do is try once again just to practice 150 00:11:38,110 --> 00:11:43,620 tried to create an decryption decryption software. 151 00:11:43,920 --> 00:11:47,540 So once again you have your encryption there and you want to decrypt your code. 152 00:11:47,550 --> 00:11:49,410 So let's say you want to decrypt all this. 153 00:11:49,500 --> 00:11:51,670 What you what you just wrote it means hello. 154 00:11:51,690 --> 00:11:57,750 I love pizza so try to do a reverse engineering reverse engineering and try to go from this to this 155 00:11:57,750 --> 00:11:58,710 right here. 156 00:11:58,830 --> 00:12:06,780 So simply recreate another software like this and try to go from this encryption to back to the normal 157 00:12:06,780 --> 00:12:09,230 word to the normal word. 158 00:12:09,510 --> 00:12:10,950 So that's it for this class guys. 159 00:12:10,980 --> 00:12:12,570 Right now you know how everything works. 160 00:12:12,570 --> 00:12:16,320 We created our small project and see all in our next class.