Placeholder Image

Subtitles section Play video

  • wait.

  • All right, This is CS 50.

  • And just eight weeks ago, 2/3 of you had never studied any computer science before.

  • And what we thought we'd begin with today is really a look back of truly how far you've come over just those several weeks.

  • In fact, it was just eight weeks ago when you first started tinkering with scratch this graphical programming language by which you could drag and drop puzzle pieces and making the computer do what you want.

  • And then a week later, you might have struggled with just getting Mario to ascend.

  • Appear mid by way of hash is that you were printing with at the time was perhaps quite non obvious.

  • But it's ever since has just been what a pair of nested four loops.

  • And then the week after that, you explored cryptography among other fields, and you learned how to encrypt.

  • And you've decrypted information like this snippet here.

  • After that, you explored some electoral processes and the implementation of algorithms that you might be familiar with from the real world, but perhaps didn't think about the trade offs and choosing one algorithm or another and then ultimately implementing it in code just a week later.

  • Did we transition to filters on instagram, implementing things like your own C P a filter so that moving forward, hopefully it won't take for granted.

  • When you click that button on the screen on your phone, you actually know where can presume we're in for what's going on underneath the hood as it changes from one setting to another.

  • And then, of course, big Board, where we handed you some 140,000 English words in a really large file.

  • And you had to implement your own spell checker a dictionary, so to speak with, using as few was using his little amount of time in his little space as you could, implementing ultimately your own hash table.

  • Thankfully, since then, we can all take for granted that those things exist.

  • But you indeed built that from scratch.

  • Just a week later, we started handing you large files like this, and of all things you were able to deduce by writing some python code that this is Lavenders Deanna, among others in the class of whose files we handed you and then most recently, or perhaps quite soon.

  • Well, you learn to apply another language in this case sequel to questions like Who has starred in films with Kevin Bacon?

  • And so a number of tools are now in your tool kit.

  • And again, I would just emphasize that eight weeks ago, 2/3 of you had never done any of that before.

  • So even if it's felt like it has never let up in each week feels all the more challenging than last.

  • Consider the Delta and consider what we promised in the first week of the class that would ultimately matters in this course is not so much where you up relative to your classmates but where you end up relative to yourself when you began.

  • And it is indeed those eight weeks ago that you began.

  • And it's today and in the course is final weeks that you will ultimately be able to compare yourself.

  • So in trying to think today about what we hope your own takeaways are from not only the course, but computer science More generally, I actually pulled up some of my own notes you might recall from Week Zero that I mentioned I took this course myself back in 1996 and what happened to be the one that turned me from a government major to a computer science major, and I didn't take many notes at first.

  • It seems, in that first class, there were a couple of other pages, and so I started flipping through these And in fact, this was my second page of notes.

  • And if you focus what's on what's up here at the top?

  • Apparently one of my first notes to myself at a function for those unfamiliar today our instructions that do the work on.

  • Indeed, if I looked down further on my notes arguments, we introduce that same first day.

  • It's info that's passed from one function to another toe.

  • Have something done by or performed on it.

  • All right, so that actually maps wonderfully cleanly to what it is.

  • We indeed started ourselves doing those eight weeks ago just talking about what CS is problem.

  • Solving a problem is just something that's got input.

  • And the goal, of course, is to produce something with output.

  • And we had to agree from that very first week how we're gonna represent these inputs and outputs, and so we might do it symbolically with letters of the alphabet we know since then, with that, we might new do it numerically, as with decimal digits or under below that we might just use binary, a different based system using only zeros and ones.

  • Or we could even represent that same capital A just using some pattern of light bulbs or switches that you turn on in some order.

  • In fact, if you think back then to these first principles that we introduce those weeks ago 20 of the students now in the audience what does this say?

  • Hi.

  • So what, indeed says hi.

  • Why is that what we just agree in weeks ago, On what numbers map to what letters?

  • And so long as all of the humans in the world agree on that, whether sending e mails or text messages or the like, our computer systems can all present information that we ultimately understand.

  • Another review question from Week zero.

  • What did this say way back when, If you need a hint, it was it was investing 128,514.

  • That way a little letter emoji.

  • This was the face with tears of joy, Right, taking all of the fun out of sending emojis Anytime you receive or send an emoji, really, all you're sending is a pattern of zeros and ones or worse the number 128,514.

  • But your computer or phone are presenting it to you in a certain way based on that context, all based on just how we humans are.

  • Those before us decided how to represent this information.

  • But of course, we don't have just those inputs and outputs.

  • There are another piece to the puzzle in, so I actually look back on my own third page of notes here and focused on my first line here back in 1996.

  • An algorithm is apparently a precise sequence of steps for getting something done, and programming more generally is, ah, process of taking an algorithm and putting it into a language a computer can process.

  • And indeed, that really was the additional puzzle piece we first focused on in Week zero.

  • It was what was inside the proverbial black box, the sort of secret sauce that you provide your input to.

  • You get your output from those air the algorithms that we've been talking about ever since now, not just in pseudo code or in English, but in CNN Python and now sequel in the coming weeks.

  • Ah, few other languages as well.

  • But of course we used algorithms to solve problems.

  • And one problem is, isn't was rather old school, and we thought we'd reflect just a bid and perhaps reinforced that same week, zero it by taking a couple of volunteers, perhaps a student and one of their family members, voluntarily or forcibly, with them.

  • You have to be comfortable, though appearing on stage and in turn, the Internet in perpetuity is the catch.

  • I see.

  • Okay, I see one volunteer and either mom or dad fighting out who's not going to go up.

  • Okay, Come on up.

  • A round of applause, if we could for our volunteers.

  • Come on over this way.

  • And what is your name?

  • Daniella.

  • Nice to meet you.

  • Come on over here.

  • And what is your name?

  • Mariano.

  • And your dad, I presume.

  • All rights.

  • Well, so nice to see you both.

  • You'll recall from week zero that one of the first problems we solved was looking up someone in a phone book.

  • Well, here I have a pretty thick yellow pages wherein there's a whole bunch of products and service is alphabetized from A to Z, and we can, of course, look up the number for someone in this book.

  • For instance, Supposed today we need Ah, plumber.

  • Could we ask Mariano to find us a plumber in this phone book?

  • Flipping through a few pages?

  • A lot of pages?

  • Yeah.

  • Okay.

  • All right.

  • And we have a page full of plumbers.

  • And now could your dad have done better?

  • Do you think?

  • I think so.

  • So would you like to show?

  • Ah, dad and other parents here what you might have done instead?

  • Oh, my goodness.

  • Okay.

  • Thank you.

  • And for those wondering, let's continue the algorithm, if you will.

  • What's your next step?

  • Nice.

  • And why are you doing this, though?

  • I opened halfway.

  • And then if it's not on the it's like we'll need to is a little strong, but you can get rid of Yes, indeed.

  • So if you keep this process going, having and having in having what should you be left with?

  • Ultimately, just the letter piece.

  • A round of applause, if we could for both of our volunteers here.

  • Thank you.

  • CS 50 stress ball for you both.

  • Thank you so much.

  • Oh, thank you.

  • Thanks.

  • So that was one of the first lessons with what you began focusing on algorithms.

  • And the point back then recall was to really emphasize the familiar right.

  • We might not use that particular technology all that much anymore, but it really is fundamentally the same thing that's now in our iPhones and Android devices and the life.

  • It just so happens that we search for things by strolling with our finger up and down.

  • But consider to even these days and 2019 when you type into the auto complete to search for someone by first name or last name.

  • How is your phone finding that information?

  • It's exactly like that not quite as physically as that, but most likely for efficiency.

  • Your phone is looking roughly in the middle of all of those names, then jumping up or down in the blink of an eye in order to find that person for you ever so quickly.

  • And so all of us might have an intuitive understanding It just like Mariano did for finding plumbers by jumping to the P section.

  • But then you came close to the p section but then started flipping.

  • And I dare say you you flip through far more pages than you ultimately needed to using arm or efficient, divide and conquer if one time only algorithm instead.

  • So beyond algorithms recall, um, I recall that I had just a few other notes.

  • My last page of notes.

  • I also had this year that what was apparently important then and no less so now is that in computer science and in turn, programming precision is important and correctness is important.

  • And indeed, one of the things you perhaps gleaned in programming, whether in scratch or see or python or sequel over the past few weeks is that the computers are really unforgiving, right?

  • They can't just in for like we humans do.

  • And frankly, I'm not sure we would want our computers to Justin.

  • For sometimes what we mean.

  • If the goal is precision and correctness, you need to be ever so precise.

  • So let's see, perhaps with one more demonstration, just how much this one has percent perhaps sunk in.

  • If we could get perhaps two more volunteers of students and family member as well student and family member here and I don't see a family member's hand up.

  • Can you convince one?

  • Okay, come on up.

  • Wonderful.

  • A round of applause for our other power volunteer, sir.

  • So now for this one, not everyone's off the hook.

  • If all of the students in the room, if they have a piece of paper and or pen or pencil could take that out and share with anyone next to you if you don't have Emma and Brian are also gonna pass out some paper and pens if you don't have a writing apparatus.

  • The goal at hand is actually for all of us to participate, thanks to our two volunteers.

  • And what's your name?

  • David.

  • Nice to see you.

  • Nice to see you as well.

  • Come on over in here.

  • And this will be a two part exercise as well.

  • And the first go at hand is for you to choose.

  • Do you want to go first or Dad?

  • Is it?

  • Would you like your dad to go first?

  • You're gonna go first.

  • All right.

  • So come on over here.

  • And what I'm gonna show David in just a moment is an image on the screen that I'm going to ask that he program you the audience to draw, giving verbal instructions only the goal of which is for him to be as precise as possible and as correct as possible to compel the audience much like a computer to follow his instructions and, in turn, implement your algorithm.

  • So in just a moment, David is going to rattle off step by step instructions for having everyone in the audience draw this.

  • You are the only one that can see what's on the screen.

  • Everyone in the audience just about has a piece of paper and a pen or pencil, and I just need you very confident Leah, clearly to recite step by step instructions by which everyone with their pen or pencil can draw what you see on the screen here make sense.

  • You may use any verbal instructions you like.

  • Okay, all right.

  • Just about ready to begin and the goal.

  • Precision correctness begin.

  • Okay, step one.

  • Draw sideway square sideways are 45 degrees rotated okay from each.

  • The bottom three corners draw a straight line down.

  • That's approximately the length of each side of the square.

  • Unfortunately, programs cannot ask questions of programmer or so we continue on with next.

  • Step on.

  • Finally, at the, uh, between the first and second line draw a line connecting the two at the end.

  • And between the second and third line draw a line connecting the end.

  • How do you feel about your instructions?

  • Precise and correct.

  • Wishy washy.

  • Wishy washy.

  • Okay.

  • All right.

  • So let's go ahead.

  • Hang onto the mic for just a moment.

  • I'm gonna hop down into the audience with our tips just to grab a few representative solutions.

  • If you wouldn't mind my grabbing a few sheets of paper from folks who have participated, let me take a few over here.

  • Just a random sample.

  • Welcome to volunteer proactively or keep it to yourself.

  • Let me go in over here.

  • Okay.

  • Thank you so much.

  • Uh, any takers over here?

  • Okay.

  • All rights.

  • Good.

  • Good, good whips.

  • Thank you and all right, that's the episode.

  • Grabbing a couple to see some over here.

  • All right, That should d'oh!

  • That's that.

  • Should d'oh let me grab these from Brian over here.

  • And Emma, those air blank.

  • All right, so I think we have plenty over here, so let's take a look before we do part two of two if I may, at how well David program to the audience.

  • I'm gonna go ahead in just a moment and pull up a projection of some of these drawings here that are the results of these operations.

  • So let me flip through, get a sample here, and I see a lot.

  • A lot of good options here.

  • I see this picture here, which may and I am doing when they could see you might see this picture here, which perhaps resembles what you Drew.

  • See this one here, top corner.

  • Very similar in spirit.

  • This one left a lot of room for other things, but this one was a little more abstract, if I may.

  • And so let me go over to a spoiler to show you what it is.

  • David was programming you to draw, and with some suspense, he was compelling you to draw.

  • We hope this here.

  • All right.

  • So close or not close, perhaps.

  • All right around the block for David, we could thank you.

  • And so you gave pretty You used if you would abstractions right in discussing this.

  • You said a sideways square used 45 degree angles hoping that folks would presumably know what you mean by that?

  • Why did you not just say draw Cube, for instance?

  • Okay, well, it would not have been cheating, but it would have been a wonderful abstraction, right?

  • If everyone in the room assuming knows when a cube is, you might then be compelled to draw it quite quickly.

  • But that two leaves ambiguity and lacks precision.

  • While how is the cube oriented?

  • Is that this way?

  • Is it that way is a curve this way.

  • So sometimes these obstructions aren't sufficiently helpful, so I probably would have done what you did as well.

  • Now, let's do one other example here.

  • If we could, I'm gonna go ahead in just a moment and projected image onto the screen that everyone in the audience can see.

  • Except you two.

  • Let me go ahead and re angle this a little bit.

  • And if father and son would like to kid together or solo draw a picture, that the audience is going to tell you how to draw.

  • So we're gonna flip the roles Now you all will see the drawing on the screen.

  • We ask that you tell our volunteers what to draw.

  • You can use any words that you want, but you cannot ask questions and no physical gestures to explain.

  • All right, Unfortunately, it's a little hard, technologically here and that the solution is going to be there.

  • The solution is going to be there.

  • So we're gonna have to kind of put some visors on you, if we could, so that you can only see straight forward.

  • And if you don't mind, ah, hugging the board as much as close as possible, but occasionally back up so that people can see what you're drawing.

  • But resist the temptation to look up over, left or right.

  • All right.

  • So for our audience, then the images.

  • And if you two could focus only on the board now only on the board and definitely not facing that screen.

  • Okay?

  • The audience is about to see the picture in question.

  • And so we need a volunteer first from the audience to call out an instruction.

  • And he stepped ones over here, make a circle.

  • I heard draw a smaller circle.

  • I didn't hear you use the eraser, but Okay, Okay.

  • Okay.

  • And no looking at May know looking at May.

  • All right, so I'll take 1/3 step.

  • So Let's go to someone else.

  • Yeah.

  • Draw vertical line from the center of the circle from the bottom of the circle and down.

  • Uh huh.

  • I hear an abstraction.

  • So we were also given 1/4 instruction draw.

  • A stick figure that appears to be walking, if that helps.

  • But I think we're gonna need to be more precise year because I could imagine a stick figure doing multiple things and multiple with Okay, maybe.

  • Step five.

  • Do we want to make any tweaks?

  • It's drawn almost upside down.

  • Triangle.

  • I heard through the legs for the legs you need to raise.

  • Okay, I heard.

  • Erase the legs and get rid of the arms.

  • Okay.

  • And step five was maybe the two legs.

  • They're like that.

  • The body from the bottom of the body draw like a triangle to represent the legs.

  • But but not that way.

  • That's good.

  • Let's move on to step six.

  • Step six.

  • Someone over here from from the bottom of the straight line.

  • Draw an upside down V.

  • I think we did that.

  • Can you step aside just so the audience can see way have a tripod.

  • Okay.

  • Okay.

  • Okay.

  • So I think we're there.

  • I think we're there.

  • One other instruction.

  • Let's see if we can take this home.

  • Yes, we're here.

  • Unless draw less than symbol from the base of the middle of the end of the circle on the left side.

  • No less than symbol.

  • Yep.

  • Yes.

  • This is what we call a condition.

  • So yes, correct.

  • I here.

  • Okay, I think we're close to more steps, maybe.

  • Well, okay.

  • From the top left of the head, draw the words High Capital H Lower case I with I think you say a line to it with the line to it.

  • Okay.

  • And can you step aside?

  • Just the audience can see.

  • I think we need just one more step.

  • One more step.

  • Okay.

  • Back here the body from the bottom of the circle on the right hand side, the base of the circle touching the base of the circle in the vertical line.

  • Going down.

  • Make make the letter.

  • L Yeah, I heard at a 15 degree angle.

  • That's right.

  • Okay.

  • I think I think could we have you take several steps back and look up And a round of applause for our volunteers?

  • That's pretty good.

  • Thank you both So much please keep the hat.

  • Yeah, congrats So clearly abstractions could be useful.

  • But they can also be challenging, right, like programming is hard.

  • And even though this one a bit off the rails here and they're verbally, this really is just programming.

  • And we're all trying to agree on a common language or common syntax to use to have the computer or in this case, are human volunteers Execute those instructions.

  • And sometimes these abstractions air.

  • Great, Right.

  • Draw a stick figure who appears to be walking.

  • I think we can all visualize what that is.

  • Unfortunately, we're all probably visualising, slightly different stick figures.

  • And that's again where precision comes into play.

  • And correctness, too.

  • Of course, sometimes for the the the chalk went off in the wrong direction.

  • So we might have to undo.

  • And of course, we've spent also the past eight weeks debugging code as well.

  • And so I wish I could say that this gets easier.

  • It were just gets absolutely easy, but it never does, because the problems you aspire to solve, whether it's in the real world or in the world of computer science and programming, are gonna be ever changing and your aspirations are going to increase.

  • And so this frustration you might feel now never really goes away, If I can say is much some 20 plus years after doing this myself.

  • But the problems you're solving with those same challenges and those same hurdles get so much more powerful, so much more interesting.

  • And again, it all started from just a few weeks ago when Morrow's pyramid was perhaps the first problem to solve.

  • Well, if we go back to where we left off here, we had, of course, a few.

  • If we go back to where we were here, we had, of course, are drawings.

  • And then ultimately this process this, I dare say, is computer science.

  • You have input.

  • You have outputs and algorithms in between.

  • But really, what are we talking about at the end of the day?

  • Well, the creation of the output of the management of information I mean, that really is what we've been talking about for the past eight weeks is information.

  • How do you process it?

  • How do you represent it?

  • How do you transform it into something Maur and ultimately solve problems with it?

  • But with this manipulation of this creation of this storage of information evermore.

  • So these days comes increasing responsibility.

  • And I dare say one of the things that we encourage you as you exit, of course like this is not just what you can do, but frankly, whether you should do it.

  • And indeed all the more relevant today in societies, of course, stories, horrifying stories off where our data has ended up, or what has happened to our data or good intentions, perhaps going to write because we haven't considered implications and what we wanted to do today is to point out a few examples off opportunities to think harder about what it is you do in the real world is just a citizen and what you do in the on the keyboard as a programmer and how you might solve problems with one's privacy and the security of one's data in mind, consider, for instance, passwords.

  • These, of course, are perhaps the most familiar thing that you and I use probably every day to secure our accounts and in turn, maintain the privacy of our information, whether it's our photographs or financial documents or e mails or text messages or the like.

  • Fortunately, passwords really aren't the best mechanism, and most of us in this room probably should be more thoughtful when it comes to making these kinds of decisions as well.

  • For instance, in 2019 already based on a very large data breach and in the announces thereof, it turns out that the top 10 passwords in the world as of this year our number one 123456 apparently the result of some website or applications requiring a password of at least six characters.

  • And this is about the least amount of effort you could do to satisfy that goal.

  • Never to password was 123456789 Slightly better.

  • Slightly more security in so far is it's longer.

  • Number three is Quartey, and if you don't know what that means, that actually describes a type of keyboard.

  • But because if you go to the top left hand corner of your keyboard and type 123456 from left to right, you will end up smelling Q W E R T.

  • Why easy to remember also pretty easy for other people to remember as well.

  • Ah, password is the number four password out there and number five is, as of this year, 61 So another way of satisfying the constraints that these people did, but with even less effort just hitting the same key again and again and again.

  • 12345678 so slightly behind the other two.

  • ABC, 123 Starting to get a little more interesting that we're combining letters and numbers.

  • 1234567 slips in there as well.

  • Number nine is password, one clearly satisfying websites that require that you not use an English word, but you include at least one symbol or letter here to there, say the bare minimum and number 10 as of this year is 12345 So it's easy to poke fun at these, and we won't call for a show of hands.

  • But odds are some of us in this room.

  • Maybe don't make eye contact.

  • Have at least one of these passwords as your own.

  • It's just all too easy then to guests.

  • Certainly these.

  • But even if you're you're sort of practicing doing a hearing to better practices than these and you're not as simplistic as I'm gonna pick an easy word or a very simple number.

  • Suppose you're actually being more thoughtful.

  • Doesn't really matter these days, right?

  • I'm gonna go ahead and turn my attention to just a moment to, ah text editing program here on my computer.

  • The students in the room will recognize this is just representative of a programming environment.

  • And today this happens to be something called visual studio code RVs code that you can download on your own Mac or PC.

  • And I'm gonna go ahead and just save a file called pin dot pie.

  • Right?

  • Many of us have not only passwords, but pins, personal identification numbers that you're supposed to keep secret and that are usually, say, six digits long.

  • Well, even if you've protected your financial accounts or some other account with a six digit code, you know, it might take a human quite a while to guess all of the possible codes that you might have chosen.

  • But it's not terribly hard for a computer.

  • In fact, we'll do it even more simply like a lot of teams with a four digit code.

  • I can simply go in program like this if I know a bit of programming and python.

  • And I can say from time import sleep I can say something like four I in range.

  • Well, let's start from 0000 and go all the way up to 9999.

  • A four digit number.

  • But turns out we need to iterated up to 10,000 because the students in the room will recall that we generate up to, but not through that value.

  • And then in here, I'm gonna go ahead and say something like, I am checking this value, I So this is to say I'm proposing to write a program in Python that will try to crack someone's pin to show how easy it is to generate as a computer all of the possible pins in the world that are four digits long.

  • So, and just to demonstrate this, I'm going to do it a little slowly by sleeping for, like, uh, 1/10 of a second between its generation.

  • So I've gone ahead and saved my file.

  • I'm gonna go ahead down here now and run python of, um, I'm gonna go down here and run python of pin dot pie and I'll go ahead and make my screen a little taller here so we can see more.

  • Whoops.

  • Ah, thank you.

  • No, thank Thank you.

  • New here.

  • Okay, so here we go.

  • We've now written a program that granted is not cracking anything, but it is demonstrating how easily and how quickly we can generate numbers from zero on up to 9999.

  • It's not quite right, right?

  • These aren't four digit code because they're being treated his numbers.

  • But there's actually syntax with which we can solve this.

  • And if you've never seen this before, you can actually just say something like this, Colin.

  • 04 And that's just gonna reform.

  • My output is being four digits, and it's gonna pad it with zeros instead.

  • So, boom, I've written a program that generates all possible four digit codes.

  • Of course, I'm deliberately sleeping.

  • That is pausing each time I'm printing something out.

  • Ah, Hacker is not going to do that.

  • They're going to try to do this as quickly as possible.

  • No need for sleep whatsoever.

  • So let me just rerun this code, getting rid of those lines.

  • Boom.

  • That's every possible four digit code that you might have on your bank account or on some email counter the like.

  • Assuming the system allows you to have a relatively short number like that, you know, you might think.

  • OK, well, what's better than four digits?

  • Five digits?

  • Let's just increase it.

  • But I think that adversary is gonna be able to crack that pin as well.

  • I'm not even over at the screen yet.

  • And it's done already, right?

  • It is not hard once you know how to program not only to use these systems for good, but in this case for some form of evil.

  • Now, maybe you're off the hook because you're not as simplistic as I claim as to use on Lee, for instance, in alphabetical or rather, a numeric code, maybe you're using Ah, word and not a word as simple as password.

  • You know, it's a more arcane word from English or perhaps some other language, you know.

  • That, too, doesn't really matter.

  • Let me go ahead and copy from our source.

  • Eight.

  • Direct from our Source eight directory today, which for the students is available online.

  • That large dictionary that we had from problem sets five.

  • Where and you loaded all of these words into dictionary your own.

  • There was 140,000.

  • Some odd words here.

  • I'm gonna go ahead and create another file, though this one called password dot pie and recall from some of our building blocks over the past few weeks How easy it is to similarly manipulate words from a dictionary.

  • Let me go ahead and again initially import sleep, just that we can see this happening.

  • I'm going to say with open large in read mode and I'm gonna call this as file.

  • And over here, I'm gonna go ahead and say now, for a word in, I want to say file and we've not perhaps seeing this one.

  • But it turns out there's a really easy python function where you can say file dot read lines.

  • And it's just gonna slurp in all of the 140,000 words from the file and allow you to reiterate over them one at a time.

  • And if I want to go ahead and print this out, I'll use print again as before, and I'm gonna go ahead and claim that I'm checking for instance, that word dot, dot, dot Just as I claim to be checking a pin.

  • Now again, I'm not checking anything.

  • I'm just demonstrating that I could be checking this fast as by simply printing out these words instead.

  • And I'm gonna go ahead and as before, sleep for 1/10 of a second on each generation.

  • But I'm also in anticipation.

  • I'm gonna call this function, which some students will recall is to strip off any white space at the end of the line.

  • Recall that in large are big dictionary.

  • There was a new line character at the end of every word.

  • So this line of code will we'll get rid of this here?

  • Yeah.

  • Question.

  • Over here.

  • Ah, what's the significance of the different colors?

  • This is happening automatically in my text editor.

  • The program I'm using to write code each ah type of word or blocks of words that I type have a different semantic meaning to the computer.

  • And so the computer is highlighting them in that way to draw my attention to different types of words.

  • Here, for instance, we have this proposition from that Does something like load someone else's code time, though in sleep or names of things that other humans have actually invented.

  • So I'm gonna go ahead now and run.

  • This is Python of past Python of, Ah, run this as python off password dot pie and we'll see, as the students will recall all of the words in the dictionary, starting with the a words than the B words than the C words and so forth all the way down through F.

  • Now, of course, I'm sleeping unnecessarily.

  • But if during this demonstration you see your own password fly by the screen, it's not that hard for an adversary to be writing code like this and not just printing out the possible passwords but trying to log into your account again and again and again until they gain access to the system.

  • And in fact, if we deliberately speed this up, let's not bother sleeping.

  • We'll get rid of all the sleep related lines as before, and now run this code.

  • Now.

  • I'm not even over at the board, and it's already done 140,000 words.

  • Which is to say, if you're choosing a password, that's just a word in the dictionary, Whether it's English or some other language, you're not off the hook.

  • You're not being so clever because anyone with a computer can check all of those codes now you might think, Well, this is why someone had a B C 123 That's not in the dictionary.

  • That's not just numbers.

  • That's not just letters.

  • But come on, if you give me a few more minutes, I bet we could write a program together that starts with letters and ends with numbers, or vice versa.

  • We could try to concoct these patterns, and granted, it's gonna get a little slower, little slower, the more complicated it gets.

  • But again, the adversary.

  • If the goal is to get your money gets your data, might have all the time in the world actually wage that attack.

  • And so I would consider moving forward exactly what the implications are off putting your data in one place or another and not thinking to actually secure it.

  • Because in the best case, someone knows only might end up getting in a worst case.

  • More than that, whether it's financial or personal might be compromised.

  • Well, when what other forms this information come, that might be our might hint of potential threats for us, too.

  • Well, you've all probably heard of cookies when it comes to the Web.

  • And indeed, if you pursue our Web track in a couple of weeks time, will you dive in deeper to what these things can do.

  • But cookies are little pieces of information that websites plants on your Mac or PC or your phone any time you visit the website.

  • Now that might seem a little creepy at first glance, and it can be used for creepy purposes, advertising and other such tracking applications among them.

  • But this is actually a very useful primitive and computer science in Web programming in that if you have the ability to plant a little file on someone's computer, it's kind of like the digital version of a hand stamp.

  • You can remember that you've seen them before, and that's actually useful, because when you log in to Gmail or whatever email account you have, you don't really want to be typing in your user name and password every time you look at a new message, right?

  • Gmail or Google would be a little obnoxious if they kept asking you.

  • Wait a minute.

  • Who are you?

  • Wait a minute.

  • Who are you?

  • These cookies are stored on your computer so that, unbeknownst to you, it's sent from you, the browser to them, the server to just remind them perpetually who you are because you've already logged in and we can actually see this.

  • Let me actually go over to my browser, and you two might be in the habit of using chrome just as I am here and I can go and chrome go to view, developer and go to developer tools.

  • And you can do this, too, at home, on your own, Mac or PC.

  • You can do this with Fire Fox or Edge or other browsers as well, and you'll see among the various things that just popped up or not terribly user friendly.

  • This is really the domain of indie developers or programmers, but I've clicked on this network tab here because on my own Mac or PC If I visit some u.

  • R l like www dot google dot com and hit Enter, I can actually see inside of Chrome all of the requests my computer has just made over the Internet for me to google dot com, and I'm gonna go ahead and click on the very first of these here, And this, too, is gonna look pretty arcane for today's purposes.

  • But it's on Lee meant to reveal what it is that's going on here.

  • Let me scroll down, down, down, down, down and you'll see a few things here.

  • Request headers, these air, little pieces of information that my Mac and a term chrome just sent to google dot com simply because I visited the website.

  • And then, if I scroll down here, we'll see response headers.

  • This is what's coming back from google dot com to my own Mac or PC, and this is the line that's interesting.

  • If you've ever heard about a cookie.

  • All it means when I say a server is planting some information or file on your computer, it's really just doing this.

  • The response you're getting from google dot com simply says literally in English set dash cookie colon and then some value.

  • And to be fair, that values pretty arcane looking.

  • It looks a little weird, apparently is gonna expire in December, so I can infer from this that Google wants to be able to remember me at least for a couple more months to the end of the year and this value here collectively would seem to be like a sort of hand stamp.

  • They've put on my computer so that if I now proceed to do searches, if I proceed to log in to Gmail, use Google calendar the like, they know who I am or they know that it's me again and again.

  • So what does this mean?

  • This means that any website you visit can certainly be tracking what it is you're doing and where it is you're going.

  • And because big companies like Google have advertising networks as part of their portfolio.

  • If ah website, that's not google dot com is something else dot com or something even else dot com, and they're using Google's advertising well, long story short.

  • These cookies, unfortunately, are sent.

  • These digital hand stamps are presented not just to those individual websites, but also to Google again and again and again because they're the middleman in this story, the advertising network that's using ads on all of these different websites.

  • So ah, here, a very fundamentally useful and compelling computer science principle can be used certainly for wonderfully useful applications, just remembering that I'm logged in, but also if you don't think twice about it, or if you want to make money off of it can be used for these other purposes as well.

  • Now we won't go down this rabbit hole today of Well, this is largely advertising.

  • What has helped make the Internet become what it is.

  • So there are tradeoffs, certainly here, but that too, has been thematic.

  • But again, I would encourage you.

  • As you discover more and more of these principles, these things you can do through code that you consider whether indeed you should be doing so as well.

  • Well, what else might you do to mitigate this?

  • While some of you might be in the habit of using at work or at home incognito motor private mode, which most browsers today support?

  • Well, what is that actually doing?

  • Well, according to Google, it says chrome won't same.

  • The following information your browsing history, cookies and site data information entered in forms and so forth.

  • Well, that means literally that even if Google or Facebook or some other website sends you a set cookie value saying please store this chrome in this case is just gonna throw it away.

  • It's gonna empty the cookie jar so to speak.

  • Once you close that incognito window, however, your browser is still sending to Google or Facebook or whatever website you're visiting those values again and again and again, your snot private within that window per se.

  • You're only private within that window with respect to everything else you have opened.

  • So, for instance, if I go now here and go to view developer and developer tools, and I have my network tab open again and I visit something like https colon slash slash dub, dub dub dot google dot com and hit Enter, you'll see that Google is indeed still planting a cookie.

  • This time I got two cookies from Google on my computer, and those cookies will exist for as long as I have this incognito window open so Google might be able to infer who I am or that I am the same person based on these cookies.

  • But they know even more than that, if I scroll back down to where we began to these request headers, the information my browser is sending to the server, you'll notice that among these values is something like this.

  • This 12 looks a little arcane.

  • Let me go ahead and zoom in on it here.

  • But it's called user agent.

  • Its format in the same way User Dash, Agent Colon and then an arcane string here.

  • But it looks like for whatever reason, my computer is telling Google without my even asking it to that I'm using a Mac Ah, that I'm running Mac OS 10.14 point six at the moment.

  • And if I keep scrolling, it's gonna tell it further that this is a specific version of Google Chrome, and this is just some of the information that is leaked deliberately and often for good purposes.

  • But these are the kinds of traces we all leave when we're using the Internet, and we want to go down this rabbit hole to.

  • But all of our computers have unique addresses.

  • You might have heard of things called I P addresses.

  • You can't just get rid of those much like you can't just remove your postal address and expect mail to still arrive.

  • All of us have unique addresses that are still being presented to these servers, and so through computer science, their courses like this, and through reading up on these kinds of topics, here on after I realized that in understanding these prints primitives, these things like cookies and how they're set can you at least then we hope, make a more informed decision as to whether to use them in that way or not, or to visit websites in some way that you know to be, um, using them for some purpose.

  • Well, what do we have besides this to to perhaps worry about in the world?

  • I dare say Snapchat is pretty popular these days.

  • And, of course, with Snapchat, there's this notion that they popularized of being able to delete photos after one second or 10 seconds or the like.

  • And in fact, you all may recall from Problem set four you implemented recover in the language called C, and you recovered.

  • Photos that had been deleted so clearly already deleted doesn't necessarily have to mean deleted.

  • And that's certainly the case, even for third party service is now.

  • To be fair, we can only guess how it is.

  • Snapchat works underneath the hood.

  • They claim to be deleting your photos after some number of seconds, but let's consider for a moment what that might actually mean because it's our information we're putting out there in this case in pictorial form, we've never used Snapchat.

  • When taking a photo, you're able to see a screen like this and allow your message to expire either never or infinitely many seconds from now or 1 to 10 seconds somewhere in between, after which the photo is deleted.

  • Well, what does that mean In the context of last week?

  • Those of you with now background in sequel might hope that what Snapchat is doing on their servers is executing a query like this delete from snaps where I d equals something.

  • And the question mark represents the idea of the snap you just sent the photograph that you just took.

  • But maybe they're doing that.

  • We as outsiders as users, have no way to audit this.

  • We can only trust what they say.

  • What if they're instead just doing something like this?

  • Update, snaps, set, deleted equals True, where I d equals question mark where that again is the identify wr of your snap.

  • Now what is this representative of Well, in the world of computer science, there's this notion of hard deletion and soft lilliputian hard delete means truly Just delete the data like throw the bits away so that they really shouldn't be recoverable.

  • Soft elite is generally implemented like this, where you literally change a zero to a one, a false to a true in your database to just remember.

  • Oh, the user deleted this.

  • But that doesn't mean we have to throw the data away.

  • This might have value for marketing purposes, for analytical purposes, business purposes or the like.

  • So, for all intents and purposes, it's deleted cause you, the user can't get it back, and no one else can see it.

  • But perhaps one or more employees at Snap can see that data.

  • And perhaps that's the kind of data that's at risk of being leaked out longer term.

  • And we've not even discussed things like backups, which to have upsides.

  • You don't want your data to get lost, but you also don't want your data to get stuck on some backup in perpetuity as well.

  • So the lesson here we would propose it's just consider right.

  • Don't just trust with some tool or some application or developer says something does decide for yourself just how much weight to give those claims and whether or not this kind of risk is worth taking photos that you might regret to wish to one send, because there really is no notion of unsent ing, no matter what it is.

  • These applications describe it as one last one that we saw just a couple of weeks ago.

  • Photo.

  • The ability to tag photos using artificial intelligence or machine learning these days are just simple pattern.

  • Matching right was incredibly easy in a few lines of python code to pick me out.

  • For instance, out of all of CS 50 staff based on relatively little information, right, this is enhanced.

  • The closest there of this is kind of a fuzzy picture.

  • Didn't represented, really just by to, ah, you know, so two eyes, a nose and a mouth that apparently resembles my particular face.

  • This was really easy to Dio, and I don't have to tell you these days that if you're on social media, all of us have probably been uploading or have had upload on our behalf photographs of us that are then tag and we have for better for worse, been just telling the world what we look like from all sorts of angles.

  • And here, too in the data perhaps be misused.

  • Yes, it's wonderfully useful when you upload an album because your friends can see Oh, that was a great night outs.

  • We can now reminisce about those memories, but someone else could be scraping all that data as we have read about having happened in the past.

  • And someone else might use that data to find you in a crowd where you don't want to be found.

  • Or governments could do this, too, based on driver's licenses, photos of the like here to Just because the software can do something doesn't necessarily mean we should do that.

  • Well, one last demo involving code.

  • If we may, I'm gonna go ahead and pull up on my computer.

  • CS 50 Zone website, which, rest assured, does not use this feature, but I can add it to it in real time.

  • Here, see his fifties website at the moment, and just as I can view developer tools before to see the network tab, I can also do this to visit what's called a consul.

  • So long story short, there is an ability in browsers to run code in a language called Java script.

  • It's another programming language, similar and spirits, a python and the like.

  • But it's very commonly used in browsers today and this little prompt here, the little carrot symbol means I can type anything I want.

  • Now there's multiple ways to add code to a website, and if you pursue society's Web track, you'll see a number of these ways.

  • But for now, I'm gonna go ahead and just do a simple example by running code to suggest just how easy it is for a website to ask the same question that you're about to see that question being.

  • Of course, you might have visited a website and seeing something like this a little pop up somewhat innocuously, maybe top left hand corner of the screen, you click it, and then, while law, some food ordering website knows where you are and so they can give you the menus in the location or some map might disappear.

  • It's actually pretty easy, frighteningly easy to do this.

  • Let me go ahead and write a little bit of code down here and I'll zoom in and then all hit enter to execute it.

  • I'm gonna go ahead and type navigator, which is Ah ah, variable available to me in Java script in a browser that lets me access something called Geo location to Geo locate.

  • Something means to locate something geographically,

wait.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it