1 00:00:00,289 --> 00:00:04,829 Welcome back. So now we need to implement 2 00:00:05,190 --> 00:00:07,980 the password checker tool 3 00:00:08,130 --> 00:00:12,270 so far. So good. Our users, they can register accounts, they can login, 4 00:00:12,529 --> 00:00:15,689 but we want to make sure that the passwords that they use 5 00:00:15,699 --> 00:00:19,270 to create their accounts in the first place is actually strong enough. 6 00:00:19,280 --> 00:00:20,959 And we have a list of criteria. We 7 00:00:21,129 --> 00:00:24,969 want to make sure that the password is at least eight characters. 8 00:00:25,190 --> 00:00:27,040 It contains a capital letter, 9 00:00:27,049 --> 00:00:33,270 it contains a number and it also contains at least one special symbol. 10 00:00:33,360 --> 00:00:36,610 Now, the symbols are what I've written over here. 11 00:00:36,619 --> 00:00:39,729 You can see I have all of them listed out. 12 00:00:40,159 --> 00:00:43,930 So what I'm gonna do is at the very top. Ok. Let's go ahead and 13 00:00:44,310 --> 00:00:46,860 let me just cut this. First of all, I'm going to cut that. 14 00:00:47,360 --> 00:00:50,319 So we're gonna have to import a library which 15 00:00:50,330 --> 00:00:53,430 is going to be the regular expressions library. 16 00:00:53,439 --> 00:00:53,900 So 17 00:00:54,540 --> 00:00:59,860 at the very top, let's say import and then re ok. So 18 00:01:00,560 --> 00:01:02,040 let me just add a note 19 00:01:02,849 --> 00:01:07,779 that says import for regular expressions. 20 00:01:08,110 --> 00:01:08,709 OK. 21 00:01:09,919 --> 00:01:12,089 All right. So now let us add 22 00:01:12,250 --> 00:01:13,330 a note 23 00:01:13,830 --> 00:01:16,879 and I will say a password, 24 00:01:17,980 --> 00:01:20,879 password checker function. 25 00:01:21,819 --> 00:01:23,540 OK? I think that's, that's fine 26 00:01:24,029 --> 00:01:25,419 password checker 27 00:01:25,989 --> 00:01:27,720 function. 28 00:01:27,970 --> 00:01:28,559 Ok. 29 00:01:28,669 --> 00:01:29,180 So 30 00:01:29,959 --> 00:01:33,620 let us create the name of the function. So I'm gonna call it define and then 31 00:01:34,099 --> 00:01:38,099 we can say is underscore strong 32 00:01:39,220 --> 00:01:40,870 uh underscore password. 33 00:01:41,110 --> 00:01:41,680 Ok. 34 00:01:41,830 --> 00:01:43,879 How about that? And now, of course, inside 35 00:01:44,080 --> 00:01:48,849 we're going to accept one variable which will be the actual password itself. 36 00:01:49,139 --> 00:01:49,889 Ok. 37 00:01:50,129 --> 00:01:52,080 And let's add a colon 38 00:01:52,529 --> 00:01:54,110 and there you go. All right. 39 00:01:54,500 --> 00:01:56,989 Let us begin to add the criteria. 40 00:01:57,000 --> 00:02:00,739 The very first criteria here will be the length of the password. So 41 00:02:00,959 --> 00:02:03,559 we can say if and now 42 00:02:04,089 --> 00:02:09,389 the function L which represent the length of what of the password? 43 00:02:10,399 --> 00:02:12,619 Ok. So if it is less, 44 00:02:13,449 --> 00:02:15,110 then eight, 45 00:02:15,509 --> 00:02:19,789 let's add our colon. What are we gonna say? We're gonna return false. 46 00:02:20,300 --> 00:02:22,110 Ok. We're gonna return false, 47 00:02:23,000 --> 00:02:27,460 actually, false capital F false comma. 48 00:02:27,880 --> 00:02:31,339 And then we can provide something like a feedback 49 00:02:31,729 --> 00:02:36,889 telling the user that, hey, your password must be at least eight characters long. 50 00:02:36,899 --> 00:02:38,660 So let's do that. Ok. 51 00:02:38,970 --> 00:02:39,669 So 52 00:02:39,850 --> 00:02:43,220 notice right now two things that happened. First of all, 53 00:02:43,539 --> 00:02:48,759 we are returning false, meaning that the password isn't strong enough. 54 00:02:48,770 --> 00:02:52,720 And then we're also providing a feedback as well. 55 00:02:53,330 --> 00:02:55,580 Keep that in mind. It's gonna be very, very important. 56 00:02:55,809 --> 00:02:58,869 Let's move on to the next criteria. 57 00:02:59,149 --> 00:03:00,669 So I'm gonna come down here 58 00:03:01,229 --> 00:03:02,990 and then say if 59 00:03:03,899 --> 00:03:05,539 and now not. 60 00:03:05,639 --> 00:03:06,300 Ok. 61 00:03:07,039 --> 00:03:07,279 R 62 00:03:07,639 --> 00:03:09,059 search, 63 00:03:09,369 --> 00:03:10,550 we want to search 64 00:03:10,830 --> 00:03:15,660 using the R module. Let me just make sure I typed it correctly, search. 65 00:03:16,089 --> 00:03:17,580 And now in brackets, 66 00:03:17,740 --> 00:03:25,300 we want search to see if there are any uppercase letters within the string. Ok. 67 00:03:25,309 --> 00:03:27,789 So we're saying we do search 68 00:03:28,179 --> 00:03:29,679 and now are 69 00:03:30,110 --> 00:03:30,710 ok. 70 00:03:31,130 --> 00:03:31,830 And now 71 00:03:32,009 --> 00:03:33,759 in code single codes, 72 00:03:33,979 --> 00:03:36,869 let's add our brackets. What are we searching for? 73 00:03:37,009 --> 00:03:39,910 We're searching for A to Z. 74 00:03:40,639 --> 00:03:43,059 So this right here is a method 75 00:03:43,309 --> 00:03:46,479 using the regular expressions library. 76 00:03:46,589 --> 00:03:50,029 We want to search through our password to check to see 77 00:03:50,039 --> 00:03:53,990 if there is any capital letter between A to Z. 78 00:03:54,029 --> 00:03:54,750 So 79 00:03:54,949 --> 00:03:56,139 A to Z 80 00:03:56,490 --> 00:04:00,199 and then comma and then in password. 81 00:04:01,570 --> 00:04:02,229 Ok. 82 00:04:03,029 --> 00:04:03,559 So 83 00:04:04,460 --> 00:04:06,990 we can return for false 84 00:04:09,779 --> 00:04:12,800 and why false? Because we said if not. 85 00:04:13,339 --> 00:04:16,298 So if the program such as through the password 86 00:04:16,309 --> 00:04:19,010 and doesn't find a capital letter A to Z, 87 00:04:19,019 --> 00:04:20,358 it's going to be not. 88 00:04:20,369 --> 00:04:25,329 So we're going to return false and then we can provide what a feedback. 89 00:04:25,410 --> 00:04:27,559 So I can say password 90 00:04:28,059 --> 00:04:28,959 must 91 00:04:29,119 --> 00:04:30,399 include, 92 00:04:31,700 --> 00:04:32,730 include 93 00:04:32,890 --> 00:04:34,290 at least 94 00:04:34,589 --> 00:04:36,850 one upper case 95 00:04:37,709 --> 00:04:39,010 uh letter. 96 00:04:40,299 --> 00:04:40,799 Ok. 97 00:04:41,779 --> 00:04:43,589 And let me add a dot Right there 98 00:04:43,880 --> 00:04:46,059 and there you go. Ok. 99 00:04:46,190 --> 00:04:49,679 Now, can you try to write the code to search 100 00:04:49,929 --> 00:04:55,959 to see if a number between zero and nine is in the password? Ok. 101 00:04:56,149 --> 00:04:59,709 We can say if not, we do search. 102 00:05:01,000 --> 00:05:02,739 Ok. And then in brackets 103 00:05:03,720 --> 00:05:06,920 R and now in single codes, I'm going to open up 104 00:05:07,200 --> 00:05:10,579 a new bracket now between 0 to 1 to 9. 105 00:05:11,230 --> 00:05:14,160 And now we're searching for the password. 106 00:05:14,170 --> 00:05:18,570 We want to know if the password has a number between zero and nine 107 00:05:18,809 --> 00:05:21,130 and of course, if it doesn't, 108 00:05:21,579 --> 00:05:23,609 we're going to return false 109 00:05:24,709 --> 00:05:28,649 and then we can say password must, must include at least one digit. 110 00:05:28,739 --> 00:05:31,049 Let me change digits to number actually. 111 00:05:32,100 --> 00:05:32,720 Ok. 112 00:05:33,829 --> 00:05:34,690 And there you go. 113 00:05:34,910 --> 00:05:37,799 So we've checked the length of the password. 114 00:05:37,809 --> 00:05:40,329 We've checked to make sure it has an uppercase letter. 115 00:05:40,399 --> 00:05:44,410 We've checked to make sure it has at least one number last but not least, 116 00:05:44,420 --> 00:05:48,130 let us check to see if it has a special symbol. 117 00:05:48,140 --> 00:05:48,559 So 118 00:05:48,820 --> 00:05:53,200 the last one I'm gonna say, if not we dot Search 119 00:05:54,079 --> 00:05:55,660 and now in brackets 120 00:05:56,359 --> 00:05:57,070 are 121 00:05:57,600 --> 00:06:01,510 singular codes. And now let's open up the main brackets 122 00:06:02,029 --> 00:06:04,100 and now I am going to paste 123 00:06:04,250 --> 00:06:06,000 all the special symbols. 124 00:06:06,600 --> 00:06:10,290 Oh, there's quite a number of them actually. Ok. So I'm gonna add that 125 00:06:10,529 --> 00:06:12,920 now comma and now password. 126 00:06:13,579 --> 00:06:14,440 Ok. 127 00:06:14,579 --> 00:06:15,820 Add a colon. 128 00:06:16,279 --> 00:06:17,119 And now 129 00:06:17,660 --> 00:06:19,000 if we don't have 130 00:06:19,100 --> 00:06:20,600 that, I'm going to return 131 00:06:21,489 --> 00:06:22,670 falls. 132 00:06:23,720 --> 00:06:27,059 Ok. And then codes I will say password 133 00:06:28,239 --> 00:06:32,019 uh, must include at least one special 134 00:06:32,730 --> 00:06:33,899 symbol. Let me change 135 00:06:34,010 --> 00:06:34,980 character, the symbol, 136 00:06:36,160 --> 00:06:36,619 same 137 00:06:38,709 --> 00:06:39,540 codes 138 00:06:39,920 --> 00:06:42,100 and there it is. Ok. 139 00:06:42,440 --> 00:06:43,019 So 140 00:06:43,179 --> 00:06:44,329 we've checked 141 00:06:44,559 --> 00:06:46,100 the four main criteria. 142 00:06:46,450 --> 00:06:47,459 However, 143 00:06:47,850 --> 00:06:53,299 what if the password that was created is actually good. It's a strong password. So 144 00:06:53,670 --> 00:06:54,649 for that, 145 00:06:54,760 --> 00:06:56,220 I'm gonna come over here 146 00:06:56,670 --> 00:06:59,000 and I'm going to return. True. 147 00:06:59,390 --> 00:07:00,109 Ok. 148 00:07:00,230 --> 00:07:05,100 I'm going to return True. And we can even print out something that says password 149 00:07:05,910 --> 00:07:07,529 is strong 150 00:07:08,940 --> 00:07:11,459 and there you go. 151 00:07:11,609 --> 00:07:12,410 So 152 00:07:12,570 --> 00:07:15,929 just to give you a very quick recap of what we've done over here, 153 00:07:16,239 --> 00:07:19,779 we imported the regular expressions library because we 154 00:07:19,790 --> 00:07:22,589 want to use a particular method of function, 155 00:07:22,839 --> 00:07:24,619 which is the search function 156 00:07:24,779 --> 00:07:30,279 to go through the password and check for specific kinds of criteria. So first of all, 157 00:07:31,079 --> 00:07:32,890 we check the length of the password. 158 00:07:33,170 --> 00:07:34,859 Is it less than eight? 159 00:07:35,140 --> 00:07:36,600 If it's less than eight, 160 00:07:36,609 --> 00:07:38,799 we return false and then provide a feedback that 161 00:07:38,809 --> 00:07:42,559 says password must be at least eight characters long. 162 00:07:42,970 --> 00:07:48,230 And now we want to search to see if there is a capital letter between A to Z. 163 00:07:48,429 --> 00:07:51,519 So we use the method re dot search 164 00:07:51,880 --> 00:07:55,679 and then in brackets R codes and then the brackets A to Z 165 00:07:56,040 --> 00:07:57,720 and then password. 166 00:07:57,970 --> 00:07:59,399 And then we provide the feedback 167 00:07:59,679 --> 00:08:02,779 and then we did the same to search for at least one number. 168 00:08:03,049 --> 00:08:05,869 And then we did the same to search for at least one special symbol. 169 00:08:06,130 --> 00:08:09,279 And then finally, if all four criteria were passed, 170 00:08:09,510 --> 00:08:11,040 we will return true. 171 00:08:11,149 --> 00:08:14,859 And then we would say password is strong. 172 00:08:15,500 --> 00:08:16,149 So 173 00:08:16,410 --> 00:08:22,299 now that we have the criteria listed out for the strength of the password, 174 00:08:22,480 --> 00:08:28,279 we now need to integrate it within the registration function and and make sure 175 00:08:28,589 --> 00:08:31,619 that before the user's account is registered, 176 00:08:32,359 --> 00:08:35,539 the password actually passes the test. 177 00:08:35,739 --> 00:08:37,337 So right here, 178 00:08:37,717 --> 00:08:41,698 once we've asked the user to provide their username and the password, before 179 00:08:41,948 --> 00:08:46,508 we begin opening up, the users do text file to store the credentials. 180 00:08:46,648 --> 00:08:50,568 Let us introduce the password checkout. So 181 00:08:51,400 --> 00:08:55,179 I can create a verbal code is valid. 182 00:08:55,679 --> 00:08:56,299 Ok. 183 00:08:56,710 --> 00:09:00,400 We're gonna check to see if the password is actually valid. 184 00:09:00,650 --> 00:09:02,219 And then also 185 00:09:02,539 --> 00:09:05,219 we've been working with what the feedback, 186 00:09:05,229 --> 00:09:09,320 feedback or message you can change the variable if you, if you want to. 187 00:09:09,330 --> 00:09:10,750 But I'm gonna go with feedback. 188 00:09:10,960 --> 00:09:11,500 Ok. 189 00:09:12,119 --> 00:09:15,419 So I'm gonna say is valid underscore feedback. 190 00:09:15,460 --> 00:09:19,590 And I'm, I'm gonna pass them into the function that we used to create a 191 00:09:19,780 --> 00:09:22,460 password which is what is strong 192 00:09:22,820 --> 00:09:24,460 underscore password. 193 00:09:25,090 --> 00:09:26,429 And then in Beckett's 194 00:09:26,679 --> 00:09:27,789 password. 195 00:09:29,020 --> 00:09:29,859 Ok. 196 00:09:31,359 --> 00:09:32,799 So now 197 00:09:33,090 --> 00:09:37,659 we can say if it's not valid, so if not 198 00:09:38,409 --> 00:09:39,750 is valid. 199 00:09:40,119 --> 00:09:45,549 So if the password they provided isn't strong enough, we can simply print 200 00:09:46,219 --> 00:09:47,390 and then we can save 201 00:09:48,400 --> 00:09:50,419 password is 202 00:09:50,950 --> 00:09:54,219 not up too much space, password is not 203 00:09:54,640 --> 00:09:56,299 strong enough. 204 00:09:57,280 --> 00:09:58,010 Ok? 205 00:09:58,859 --> 00:10:00,159 And then 206 00:10:00,559 --> 00:10:02,039 what else can we do? 207 00:10:02,200 --> 00:10:04,409 We can print the feedback 208 00:10:04,729 --> 00:10:05,840 saying, hey, 209 00:10:05,849 --> 00:10:08,510 your password needs at least one number or your 210 00:10:08,520 --> 00:10:10,630 password must include at least one uppercase letter. 211 00:10:10,640 --> 00:10:11,099 So 212 00:10:11,309 --> 00:10:12,650 I can come down here, 213 00:10:12,869 --> 00:10:14,880 add another print statement 214 00:10:15,520 --> 00:10:19,179 and just simply pass in the feed back 215 00:10:19,869 --> 00:10:20,450 and 216 00:10:20,619 --> 00:10:25,650 there you go last but not least we are simply going to return 217 00:10:27,700 --> 00:10:28,280 and 218 00:10:28,489 --> 00:10:30,080 there you go. 219 00:10:30,239 --> 00:10:34,119 So that is the way how we can implement 220 00:10:34,359 --> 00:10:37,250 the password checker tool. 221 00:10:37,359 --> 00:10:39,200 We've listed out the criteria 222 00:10:39,520 --> 00:10:40,559 length 223 00:10:40,789 --> 00:10:43,440 number, uppercase letter symbol 224 00:10:43,789 --> 00:10:46,119 and now where you have the registration function 225 00:10:46,419 --> 00:10:47,960 we've added, ok, 226 00:10:48,320 --> 00:10:51,090 if the password isn't valid, 227 00:10:51,590 --> 00:10:56,599 say it's not strong enough and then also provide the feedback as well, 228 00:10:57,109 --> 00:10:59,179 otherwise simply return. 229 00:10:59,349 --> 00:11:03,400 So now let's check to see if it's working. Hopefully it should. So let's run. 230 00:11:03,739 --> 00:11:05,909 Ok, I'm going to register 231 00:11:06,500 --> 00:11:12,859 username, let's say Bob uh password. I'm gonna go with capital letter San 232 00:11:13,349 --> 00:11:16,539 6123 233 00:11:16,830 --> 00:11:17,909 BV, 234 00:11:18,679 --> 00:11:22,820 press enter and awesome. It says password is not strong enough. 235 00:11:22,830 --> 00:11:26,270 Password must include at least one special symbol. Ok. 236 00:11:26,280 --> 00:11:28,700 I'm gonna open up the users 0.60 file and make sure that. 237 00:11:28,710 --> 00:11:32,309 Ok, make sure Bob wasn't created. Awesome. 238 00:11:32,479 --> 00:11:33,590 Let's go back 239 00:11:34,390 --> 00:11:37,549 and now let us try to create an actual real account. 240 00:11:38,000 --> 00:11:40,469 So let's call Alice 241 00:11:40,729 --> 00:11:45,010 password, pop 242 00:11:45,469 --> 00:11:46,900 34 243 00:11:47,789 --> 00:11:51,929 SDR and then the at symbol I think they should be strong enough. 244 00:11:52,409 --> 00:11:54,270 There you go. Ok. Awesome. User is 245 00:11:54,469 --> 00:11:55,500 so successful. 246 00:11:55,739 --> 00:11:58,869 And now if I go back to my users dot TXT, there you go. 247 00:11:58,880 --> 00:12:02,690 Now we have Alice and her password. 248 00:12:02,960 --> 00:12:07,039 So congratulations. We have enhanced our program, 249 00:12:07,210 --> 00:12:11,330 our software to now include a password checker as well. 250 00:12:11,460 --> 00:12:12,179 Join me in the 251 00:12:12,280 --> 00:12:14,419 next video where we're going to go ahead 252 00:12:15,109 --> 00:12:19,809 and also learn how we can encrypt our passwords. I see you then.