1 00:00:00,009 --> 00:00:02,230 So you're already familiar with the different 2 00:00:02,240 --> 00:00:05,280 ways of printing out your string variables, 3 00:00:05,590 --> 00:00:09,909 what I have on my screen right here. I created the variable username 4 00:00:10,189 --> 00:00:13,229 and assigned the value of cyber as a string to it. 5 00:00:13,239 --> 00:00:15,109 And then I simply said print username 6 00:00:15,250 --> 00:00:19,750 that of course resulted in printing out cyber very, very simple, very basic. 7 00:00:20,299 --> 00:00:22,229 And now from line four, 8 00:00:22,239 --> 00:00:26,069 I assigned the exact same value cyber to the variable username. 9 00:00:26,620 --> 00:00:28,600 But notice that line five and six, 10 00:00:28,610 --> 00:00:32,598 I demonstrate two different ways of printing out the variable 11 00:00:32,990 --> 00:00:35,060 I could have said welcome to the world of programming 12 00:00:35,069 --> 00:00:38,830 and then comma and then the name of the variable, 13 00:00:38,840 --> 00:00:41,110 which is of course, user name, 14 00:00:41,540 --> 00:00:42,209 Cyber 15 00:00:42,409 --> 00:00:45,169 and the output is welcome to the world of programming cyber. 16 00:00:45,330 --> 00:00:50,159 And then on line six instead of using the comma sign, I use the plus symbol. 17 00:00:50,450 --> 00:00:51,770 And this basically is what we call 18 00:00:51,779 --> 00:00:54,950 concatenation whenever you're using the plus symbol 19 00:00:55,250 --> 00:00:57,930 and then you have the exact same output. However, 20 00:00:58,220 --> 00:01:01,029 notice that there is a slight difference in the spacing 21 00:01:01,270 --> 00:01:03,360 with the comma symbol, 22 00:01:03,369 --> 00:01:07,139 you tend to have a bit more space in between your string and then the actual 23 00:01:07,769 --> 00:01:09,739 a name of your variable. 24 00:01:09,919 --> 00:01:14,349 Nevertheless, both methods work pretty well. It's only a matter of choice. 25 00:01:15,129 --> 00:01:21,129 However, let me show you a few other basic ways of manipulating your strength. So 26 00:01:21,580 --> 00:01:26,790 say, for example, I wanted to print cyber 10 times, 27 00:01:27,050 --> 00:01:27,510 right? 28 00:01:28,239 --> 00:01:32,290 Instead of me creating username, cyber, username, cyber, username, 29 00:01:32,300 --> 00:01:33,360 cyber 10 times. 30 00:01:33,610 --> 00:01:35,410 What I could simply do right here is I could 31 00:01:35,419 --> 00:01:38,209 just add the asteric symbol and then just say times 10 32 00:01:38,650 --> 00:01:39,379 and then 33 00:01:39,529 --> 00:01:41,940 all I have to do right now is just to simply print 34 00:01:42,290 --> 00:01:43,059 the username. 35 00:01:43,830 --> 00:01:46,959 And if I run the program, you can see we have cyber, cyber, cyber, cyber, 36 00:01:46,970 --> 00:01:48,010 cyber 10 times. 37 00:01:48,319 --> 00:01:51,089 And if I want space in between my words, 38 00:01:51,300 --> 00:01:54,019 I can just add a space between the R letter 39 00:01:54,379 --> 00:01:55,540 and the closing code. 40 00:01:55,660 --> 00:01:56,930 And if I run the program again, 41 00:01:57,169 --> 00:01:59,430 there you go. We have Cyber, Cyber, cyber. 42 00:01:59,970 --> 00:02:02,730 So this is what we call repetition, right? 43 00:02:03,709 --> 00:02:08,229 One of the function I wanted to let you know regarding strings 44 00:02:08,350 --> 00:02:11,970 is the length of a string. We can determine 45 00:02:12,270 --> 00:02:16,100 how long a string is. Basically, in other words, 46 00:02:16,210 --> 00:02:20,889 we can determine the number of characters in a string. 47 00:02:21,300 --> 00:02:22,850 So for example, 48 00:02:23,070 --> 00:02:24,009 over here, 49 00:02:24,660 --> 00:02:27,720 if I wanted to figure out how many 50 00:02:28,000 --> 00:02:30,880 characters were in cyber, 51 00:02:31,160 --> 00:02:35,559 all I have to do is to come over here after the print function, 52 00:02:35,570 --> 00:02:38,960 I can introduce another function called the length function, 53 00:02:39,179 --> 00:02:41,500 which is of course, Len 54 00:02:41,750 --> 00:02:44,440 and then I will have to add my closing 55 00:02:44,550 --> 00:02:45,759 bracket by that. 56 00:02:46,009 --> 00:02:50,160 And now if I run the program, can you guess what the value is going to be? 57 00:02:50,619 --> 00:02:52,639 The value is going to be five 58 00:02:52,770 --> 00:02:58,020 because cyber is made up of five characters, five letters. 59 00:02:58,220 --> 00:03:02,570 Now, you might be wondering, ok, this is all good. But how is this relevant? 60 00:03:02,580 --> 00:03:05,880 How do we apply this in the world of cybersecurity specifically? 61 00:03:06,559 --> 00:03:09,179 I'm pretty sure you must have seen on websites before where 62 00:03:09,800 --> 00:03:11,149 they ask you to log in, 63 00:03:11,410 --> 00:03:14,440 you begin to type in your password, 64 00:03:14,649 --> 00:03:17,850 but then you don't see the actual characters instead, 65 00:03:17,860 --> 00:03:20,149 you might see like the dash symbol or 66 00:03:20,270 --> 00:03:23,660 most commonly the asterisk symbol in their place. 67 00:03:23,830 --> 00:03:25,710 We can use the knowledge we've gained so 68 00:03:25,720 --> 00:03:28,220 far to actually recreate a similar scenario. 69 00:03:28,229 --> 00:03:28,639 So 70 00:03:28,740 --> 00:03:29,869 check this out. OK, 71 00:03:30,110 --> 00:03:34,070 I'm gonna create a new variable right now and call it password. 72 00:03:34,330 --> 00:03:38,770 And now let's add the actual password. I'm gonna say swordfish, 73 00:03:39,139 --> 00:03:41,419 which isn't exactly the best password, but 74 00:03:41,710 --> 00:03:43,919 never mind. We're gonna go with saltfish. 75 00:03:44,190 --> 00:03:44,919 So now 76 00:03:45,110 --> 00:03:46,399 I want to print out 77 00:03:46,710 --> 00:03:50,919 swd fish. So I can just say print a password, right? 78 00:03:51,070 --> 00:03:54,460 So if I run the program, it's gonna say salt fish, but 79 00:03:54,589 --> 00:04:00,720 we want to replace each letter in saltfish with the asterisk symbol. 80 00:04:00,809 --> 00:04:01,369 So basically, 81 00:04:01,380 --> 00:04:05,839 we should have nine asterisk symbols in place of the actual letters themselves. 82 00:04:05,850 --> 00:04:06,759 So what do we do? 83 00:04:07,300 --> 00:04:09,919 I can create another variable right now 84 00:04:10,179 --> 00:04:12,199 and call it the masked 85 00:04:12,630 --> 00:04:14,839 underscore password. 86 00:04:15,970 --> 00:04:18,010 And now this will be equal to what 87 00:04:18,220 --> 00:04:22,510 I'm going to add my quotes and now add the asteric symbol. 88 00:04:22,920 --> 00:04:24,630 Ok. The asteric symbol 89 00:04:25,029 --> 00:04:28,230 and now multiply it again 90 00:04:28,579 --> 00:04:34,470 by the length of the characters of our password string. 91 00:04:34,959 --> 00:04:35,950 And there it is. 92 00:04:36,619 --> 00:04:39,640 So now if I run the program 93 00:04:40,940 --> 00:04:44,730 and that did not work, oh, do forgive me for the print password. 94 00:04:44,739 --> 00:04:48,279 We need to change line three here to mask the password because 95 00:04:48,480 --> 00:04:51,600 we're no longer printing out the password. Oops, that was a bit embarrassing. 96 00:04:52,579 --> 00:04:53,440 Ok. So 97 00:04:54,040 --> 00:04:56,920 we're gonna print out the mask password now. And if I run the program, 98 00:04:57,309 --> 00:05:00,000 there you go. Ok. So now we have nine 99 00:05:00,260 --> 00:05:05,339 asterisk symbols because SUF fish itself is made up of nine letters 100 00:05:05,489 --> 00:05:08,779 and just to prove to you that this actually works if I added 101 00:05:08,880 --> 00:05:12,040 three more characters, digits in this case right now, 123. 102 00:05:12,410 --> 00:05:14,359 And when it again, now you can see the number of 103 00:05:14,470 --> 00:05:14,480 ahe 104 00:05:14,619 --> 00:05:19,359 symbols has increased by three instead of nine, it is now 12. 105 00:05:19,470 --> 00:05:25,920 So this is how you could recreate something very similar in your real world program. 106 00:05:25,929 --> 00:05:26,750 If you wanted to create 107 00:05:26,929 --> 00:05:28,769 a masked password system, 108 00:05:28,899 --> 00:05:32,929 you can use these kinds of concepts. So thank you for watching the video. 109 00:05:32,940 --> 00:05:34,609 I will see you in the next class.