All language subtitles for 11. Generating a Random Password

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,560 --> 00:00:05,160 We now have all the information we need a recorded inside of our class component to actually generate 2 00:00:05,160 --> 00:00:06,070 a password. 3 00:00:06,090 --> 00:00:10,050 We know the length and whether or not to include numbers letters and symbols. 4 00:00:10,200 --> 00:00:14,370 Now we can go down to our generate password function or the function that gets called anytime a user 5 00:00:14,370 --> 00:00:19,560 clicks on that generate password button to make sure that we use this data to generate a password and 6 00:00:19,560 --> 00:00:24,460 it will use the password we generate to update the password property right here. 7 00:00:24,450 --> 00:00:29,340 Remember anytime that we update this password property that is going to cause angular to spring into 8 00:00:29,340 --> 00:00:34,930 action it's going to take that updated property and use it to update the value of the input. 9 00:00:34,950 --> 00:00:38,140 Down here let's get to it. 10 00:00:38,170 --> 00:00:42,690 I'm going to first go down to the very bottom this file where we defined our on button click function. 11 00:00:42,860 --> 00:00:45,160 But once again our goal is pretty much this right here. 12 00:00:45,160 --> 00:00:49,570 We want to eventually assign a new string to the this dot password property. 13 00:00:49,700 --> 00:00:55,060 And as soon as we do that is going to show up inside of that input right there OK. 14 00:00:55,090 --> 00:00:58,860 So I got to delete everything inside of the on button click function. 15 00:00:59,040 --> 00:01:03,350 Now watch you know right away that there are many different ways to generate a random password. 16 00:01:03,350 --> 00:01:06,930 I'm just going to show you a pretty simple and straightforward way of doing it. 17 00:01:06,950 --> 00:01:10,850 We're going to go through this implementation kind of quickly because this is kind of like some general 18 00:01:10,850 --> 00:01:11,780 programming stuff. 19 00:01:11,820 --> 00:01:16,130 It's not really specific to angular and I really want to focus on angular as much as possible in the 20 00:01:16,130 --> 00:01:18,070 first part of this course. 21 00:01:18,080 --> 00:01:18,290 OK. 22 00:01:18,320 --> 00:01:23,180 So inside of on button click we're going to first list out inside of three different variables all of 23 00:01:23,180 --> 00:01:27,190 the possible characters that can be used inside of a password. 24 00:01:27,230 --> 00:01:30,760 Going to say const numbers is going to be a string. 25 00:01:30,880 --> 00:01:32,550 It has all the possible numbers. 26 00:01:32,570 --> 00:01:36,940 So 1 2 3 4 5 6 7 8 9 0. 27 00:01:37,060 --> 00:01:51,410 Well then do the same thing for letters that will be ABC TFG H I J K element O P R S T U R STV and Y 28 00:01:51,490 --> 00:01:51,920 Z. 29 00:01:52,010 --> 00:01:52,550 Close enough. 30 00:01:52,550 --> 00:01:53,790 There we go. 31 00:01:53,810 --> 00:01:55,500 And finally symbols as well. 32 00:01:55,760 --> 00:01:56,330 I'm going to say that. 33 00:01:56,330 --> 00:01:58,210 Valid symbols instead of a password will be. 34 00:01:58,210 --> 00:02:04,500 Exclamation at count basically just right across the top row of my keyboard. 35 00:02:04,580 --> 00:02:06,810 So. 36 00:02:06,980 --> 00:02:07,220 All right. 37 00:02:07,220 --> 00:02:12,010 So we've now got all the possible valid characters that can go into a password. 38 00:02:12,210 --> 00:02:18,950 Well then create a new string called valid chars short for valid characters and I'll assign it an empty 39 00:02:18,950 --> 00:02:20,810 string for now. 40 00:02:20,840 --> 00:02:26,970 Right after that we're going to take a look at what value we have or include letters numbers and symbols. 41 00:02:27,170 --> 00:02:31,560 If any of these are true then we're going to take the appropriate character set. 42 00:02:31,550 --> 00:02:37,830 So in other words these different character sets right here and add them in to the valid char string. 43 00:02:37,850 --> 00:02:45,320 Let me show you what I mean right after valid chars will say if this dot include letters then I want 44 00:02:45,320 --> 00:02:50,830 to take the entire set of letters and add them into the pool of puzzle valid characters for the password. 45 00:02:50,840 --> 00:02:57,770 I'm about to generate let's say valid chars let's equals which just means take all of the letters right 46 00:02:57,770 --> 00:03:05,220 here and add them to the end of this string plus equals letters like so I'll then repeat that process 47 00:03:05,220 --> 00:03:07,020 for the other two flags we have as well. 48 00:03:07,050 --> 00:03:09,270 So say if this dot include numbers 49 00:03:12,760 --> 00:03:17,770 valid chars plus equals numbers. 50 00:03:17,930 --> 00:03:26,700 And then finally if this start include symbols Valot chars plus equals symbols 51 00:03:30,980 --> 00:03:37,460 the now valid chars is a string that has all the valid characters that we can possibly add into a password. 52 00:03:37,460 --> 00:03:42,590 Now the last step we're going to set up a little for loop we're going to iterate from zero all the way 53 00:03:42,590 --> 00:03:49,090 up to whatever our length of password is then for every step of our for loop we're going to select a 54 00:03:49,090 --> 00:03:55,720 character at random out of this valid chars array and use that randomly selected character to form up 55 00:03:55,750 --> 00:04:01,380 our password though the last step after that if statement right there are going to create a little local 56 00:04:01,380 --> 00:04:08,980 variable called generated password and I'll default it to be an empty string and I'll set up my for 57 00:04:08,980 --> 00:04:21,390 loop we'll say for let I journey at zero going all the way up to less than this length I plus plus then 58 00:04:21,390 --> 00:04:28,920 inside of here we will pick out a random character from the valid char string to do so we need to calculate 59 00:04:28,920 --> 00:04:31,260 really a random index inside there. 60 00:04:31,470 --> 00:04:41,170 So to find a random index will say constant X is math dot law and we'll pick a random number and multiply 61 00:04:41,170 --> 00:04:48,990 it by valid chars not link I'll zoom out for just a second so you can see it that whole line again this 62 00:04:48,990 --> 00:04:54,060 is going to take a look at the length of the valid characters array it's going to multiply it by a random 63 00:04:54,060 --> 00:04:59,100 number to give us a random number between 0 and that length then we're just going to round down to the 64 00:04:59,100 --> 00:05:06,280 nearest integer then we'll take that index and use it to look up a random character or I should say 65 00:05:06,310 --> 00:05:11,800 a specific character inside the valid chars array and we'll add again to the end of the generated password 66 00:05:11,800 --> 00:05:20,760 variable we'll say generated password plus equals valid chars at that particular index and that's it 67 00:05:20,800 --> 00:05:26,020 that's how we generate a random password now remember the end goal of this entire function right here 68 00:05:26,230 --> 00:05:32,410 on button click the very end goal whatever password we generate inside of here you have to assign back 69 00:05:32,410 --> 00:05:37,810 to the password property because that is what is going to actually get our H to mail display to be updated 70 00:05:37,900 --> 00:05:46,260 automatically by angular though right after that for loop I'm going to take the generated password and 71 00:05:46,260 --> 00:05:53,850 we'll assign it to the this stop password property we'll say this dot password sign it 2 generated password 72 00:05:55,360 --> 00:06:02,710 and that is it let's save this and we'll do a quick test we're gonna flip back over to enter in a length 73 00:06:02,710 --> 00:06:08,890 of ten and then I'll select use letters and click on generate now I can see a random string of characters 74 00:06:09,550 --> 00:06:14,870 if I also select use numbers now I've got a password with numbers and if I also add in symbols. 75 00:06:14,890 --> 00:06:19,950 Yep got some symbols in there as well if I start to remove things like let's say numbers. 76 00:06:20,080 --> 00:06:22,560 Okay now I've got only letters and symbols. 77 00:06:22,760 --> 00:06:27,840 Let's say this works out pretty well and there are one or two things about this little tool that are 78 00:06:27,840 --> 00:06:29,070 still a little bit awkward. 79 00:06:29,610 --> 00:06:34,080 Let's take a quick pause right here and fix up one or two very quick things inside the next video. 8978

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.