CS50 Video Player
    • 🧁

    • 🍬

    • 🥥

    • 🍿
    • 0:00:00Introduction
    • 0:01:01Recap
    • 0:03:56MIT Hack
    • 0:08:06Looking Ahead
    • 0:15:00Thank you
    • 0:18:03Passwords
    • 0:41:22Password Managers
    • 0:43:06Two-Factor Authentication
    • 0:46:19Hashing
    • 0:57:08Cryptography
    • 1:02:17Passkeys
    • 1:05:01Encryption
    • 1:08:23Deletion
    • 1:13:33Ransomware
    • 1:15:40CS50 Quiz Show
    • 0:00:00[MUSIC PLAYING]
    • 0:01:01DAVID MALAN: All right, one last time.
    • 0:01:04This is CS50, and we realize this has been a bit of a fire hose
    • 0:01:09over the past-- thank you.
    • 0:01:10[APPLAUSE]
    • 0:01:14Thank you.
    • 0:01:15We realize this has been a bit of a fire hose.
    • 0:01:17Indeed, recall that we began the class in week 0,
    • 0:01:20months ago with this here MIT hack, wherein
    • 0:01:23a fire hose was connected to a fire hydrant,
    • 0:01:26in turn connected to a water fountain.
    • 0:01:27And it really spoke to just how much information
    • 0:01:29we predicted would be sort of flowing at you over the past few months.
    • 0:01:32If you are feeling all these weeks later that it never actually
    • 0:01:35got easy, and with pset 1 to pset 2, pset 3 on to pset 9,
    • 0:01:40you never quite felt like you got your footing,
    • 0:01:42realize that it's kind of by design because every time you did get your--
    • 0:01:46every time you did get your footing, our goal
    • 0:01:48was to ratchet things up a little bit more
    • 0:01:50so that you feel like you're still getting
    • 0:01:52something out of that final week.
    • 0:01:53And indeed, that final week is now behind us.
    • 0:01:55All that remains ahead of us is the final project.
    • 0:01:57And what we thought we'd do today is recap a little bit of where we began
    • 0:02:01and where you hopefully now are.
    • 0:02:03Take a look at the world of cybersecurity,
    • 0:02:05because it's a scary place out there, but hopefully you're
    • 0:02:07all the more equipped now with a mental model
    • 0:02:09and vocabulary to evaluate threats in the real world, and as educated people,
    • 0:02:14make decisions, be it in industry, be it in government,
    • 0:02:17be it in your own personal or professional lives.
    • 0:02:19And we hope ultimately, too, that you've walked away
    • 0:02:22with a very practical skill, including how
    • 0:02:24to program in C, how to program in Python,
    • 0:02:26how to program in SQL, how to program in JavaScript
    • 0:02:29in the context, for instance, of even more HTML, CSS, and the like.
    • 0:02:32But most importantly, we hope that you've really walked away
    • 0:02:35with an understanding of how to program.
    • 0:02:37Like, you're not going to have CS50 by your side or even the duck by your side
    • 0:02:41forever.
    • 0:02:42You're going to have really, that foundation that hopefully you'll
    • 0:02:45walk out of here today having accumulated over the past few months.
    • 0:02:47And even though the world's languages are going to change,
    • 0:02:50new technologies are going to exist tomorrow, hopefully,
    • 0:02:52you'll find that a lot of the foundations
    • 0:02:54over the past several months really do stay with you
    • 0:02:56and allow you to bootstrap to a new understanding,
    • 0:02:59even if you never take another CS course again.
    • 0:03:02Ultimately, we claim that this was all about solving problems.
    • 0:03:05And hopefully, we've kind of cleaned up your thinking a little bit,
    • 0:03:08given you more tools in your toolkit to think and evaluate and solve
    • 0:03:11problems more methodically, not only in code, but just algorithmically as well.
    • 0:03:16And keep this mind too.
    • 0:03:17If you're still feeling like, oh, I never really quite got your footing--
    • 0:03:21my footing, think back to how hard Mario might have felt some three months ago.
    • 0:03:26But what ultimately matters in this course is indeed, not so much
    • 0:03:29where you end up relative to your classmates,
    • 0:03:31but where you end up relative to yourself when you began.
    • 0:03:34So here we are, and consider that there delta.
    • 0:03:36And if you don't believe me, like, literally go back this weekend
    • 0:03:39or sometime soon, try implementing Mario in C. And I do
    • 0:03:43dare say it's going to come a little more readily to you.
    • 0:03:45Even if you need to Google something, ask the duck something,
    • 0:03:48ask ChatGPT something just to remember some stupid syntactic detail,
    • 0:03:52the ideas hopefully are with you now for some time.
    • 0:03:55So that there hack is actually fully documented here in MIT.
    • 0:03:59Our friends down the road have a tradition
    • 0:04:01of doing such things every year.
    • 0:04:03One year, one of my favorites was they turned the dome of MIT
    • 0:04:05into a recreation of R2-D2.
    • 0:04:08So there's a rich history of going to great lengths to prank each other,
    • 0:04:13or even us here Harvard folks akin to the Harvard Yale video
    • 0:04:17we took a look at last time.
    • 0:04:18And this duck has really become a defining characteristic
    • 0:04:22of late of CS50, so much so that last year, the CS50 Hackathon, we invited
    • 0:04:26the duck along.
    • 0:04:27It posed, as it is here, for photographs with your classmates past.
    • 0:04:32And then around like, 4:00 AM, it disappeared, and the duck went missing.
    • 0:04:38And we were about to head off to IHOP, our friends from Yale.
    • 0:04:42Your former classmates had just kind of packed up
    • 0:04:44and started driving back to New haven.
    • 0:04:45And I'm ashamed to say our first thought was that Yale took it.
    • 0:04:49And we texted our TA friends on the shuttle buses, 4:30 AM asking, hey,
    • 0:04:55did you take our duck because we kind of need it next week for the CS50 fair?
    • 0:04:58And I'm ashamed to say that we thought so, but it was not in fact, them.
    • 0:05:02It was this guy instead, down the road.
    • 0:05:05Because a few hours later after I think, no sleep on much of our part,
    • 0:05:09we got the equivalent of a ransom email.
    • 0:05:12"Hi, David, it's your friend, bbd.
    • 0:05:15I hope you're well and not too worried after I left so abruptly
    • 0:05:18yesterday night after such a successful Hackathon and semester so far.
    • 0:05:21I just needed to unwind a bit and take a trip to new places and fresh air.
    • 0:05:25Don't worry though, I will return safe, sound, healthy, home
    • 0:05:28once I am more relaxed.
    • 0:05:29As of right now, I'm just spending some few days with our tech friends
    • 0:05:32up Massachusetts Avenue.
    • 0:05:34They gave me a hand on moving tonight.
    • 0:05:36For some reason, I could never find my feet, and they've been amazing hosts.
    • 0:05:40I will see you soon and I will miss you and Harvard specially our students.
    • 0:05:43Sincerely yours, CS50 bbd."
    • 0:05:46So almost a perfect hack.
    • 0:05:47They didn't quite get the DDB detail quite right.
    • 0:05:51But after this, they proceeded to make a scavenger hunt of sorts of clues here.
    • 0:05:58This here is Hundredville.
    • 0:06:00And so in Hundredville, they handed out flyers to students at MIT,
    • 0:06:03inviting folks to write a Python program to solve a mystery.
    • 0:06:06"The CS50 duck has been stolen.
    • 0:06:07The town of Hundredville has been called on you
    • 0:06:09to solve the mystery of the-- authorities
    • 0:06:11believe that the thief stole the duck and then shortly thereafter took
    • 0:06:15a walk out of town.
    • 0:06:16Your goal is to identify who the thief is, what school the thief escaped to,
    • 0:06:19and who the thief's accomplice is who helped them escape.
    • 0:06:22This took place on December 2, 2022, and took place at the CS50 Hackathon."
    • 0:06:29In the days to come, we proceeded to receive a series of ransom postcards
    • 0:06:32as the duck traveled, not only to MIT to Professor John Guttag 6.100B class,
    • 0:06:40which is a rough equivalent of CS50 down the road.
    • 0:06:43Pictured there our CS50 duck with some tape on its torso.
    • 0:06:47But then the duck took, apparently, a ride,
    • 0:06:50either in actuality or with Photoshop, not only there,
    • 0:06:53took a tour of the Charles River in front of Harvard,
    • 0:06:56the Charles in front of Boston.
    • 0:06:59It went all the way over to Yale.
    • 0:07:01We then received this postcard from Princeton
    • 0:07:03all the way over from Stanford.
    • 0:07:06Duck took a flight according to this photo here,
    • 0:07:09and then saw a bit of the world as well.
    • 0:07:12So eventually, we received a follow-up email saying, "Hi, David.
    • 0:07:15I intend to arrive for the fair between 8:37 AM and 9:47 AM.
    • 0:07:19It would be easier for my MIT hacker friends to bring me to the right
    • 0:07:22location if there's someone waiting there with a sign that says 'Duck'."
    • 0:07:26I'm not sure if we actually stood there with a sign holding duck,
    • 0:07:29but it turns out they came actually earlier in the morning
    • 0:07:32to escape detection altogether.
    • 0:07:33The duck found its home and everyone lived happily ever after.
    • 0:07:37And here the duck is again today.
    • 0:07:39But our props to our friends down the road at MIT
    • 0:07:41for returning the duck safely and for going to such crazy lengths
    • 0:07:45to put us in the annals of MIT's Hacks Gallery.
    • 0:07:49In fact, in exchange for this, we sent them a little package.
    • 0:07:53And without telling you what it is, you can read more
    • 0:07:55about this here hack that's now been immortalized
    • 0:07:57on hacks.mit.edu at this URL here.
    • 0:08:01So maybe round of applause for our friends
    • 0:08:03down the road for having pulled that off a year ago.
    • 0:08:06[APPLAUSE]
    • 0:08:07So before we dive into some of today's material,
    • 0:08:12I wanted to give you a sense of what lies ahead as well.
    • 0:08:15So this year's CS50 Hackathon is an annual tradition,
    • 0:08:17whereby students here at Harvard and our friends from Yale who
    • 0:08:20will take buses in the other direction to join us
    • 0:08:22in about a week's time for an epic all-nighter, starting roughly at 7:00
    • 0:08:26PM ending roughly at 7:00 AM will be punctuated
    • 0:08:28by multiple meals, first meal-- first dinner around 9:00 PM, second dinner
    • 0:08:32around 1:00 AM.
    • 0:08:33And those of you who still have the energy
    • 0:08:35and are still awake around 5:00 AM, we'll hop in a shuttle bus
    • 0:08:38and head down to IHOP, the larger one down the road,
    • 0:08:41not the one in the square, and have a little bit of breakfast together.
    • 0:08:44The evening typically begins a little bit
    • 0:08:46like this with a lot of energy, the focus of which
    • 0:08:48is entirely on final projects.
    • 0:08:50The staff will be present, but the intent
    • 0:08:52is not to be 12 hours of office hours.
    • 0:08:54Indeed, the staff will be working on their own projects or psets,
    • 0:08:57final projects, and the like, but to guide you toward and point you
    • 0:09:01in the direction of solutions to new problems you have.
    • 0:09:03And we do think that the duck, and in turn, AI, CS50.ai and other tools
    • 0:09:09you'll now be able to use, including the actual ChatGPT, the actual GitHub
    • 0:09:13Copilot, or other AI tools which are now reasonable to use
    • 0:09:17at this point in the semester as you off board from CS50
    • 0:09:19and enter the real world.
    • 0:09:21Should be an opportunity for you to take your newfound knowledge of software
    • 0:09:24out for a spin and build something of your very own, something
    • 0:09:27that even maybe the TFs and myself have never dabbled in before,
    • 0:09:30but with all of this now software support by your side.
    • 0:09:33This here is our very own CS50 shuttles that will take us then to IHOP.
    • 0:09:37And then a week after that is the epic CS50
    • 0:09:40fair, which will be an opportunity to showcase what it is you'll
    • 0:09:43pull off over the next few weeks to students, faculty,
    • 0:09:46and staff across campus.
    • 0:09:47More details to come, but you'll bring over your laptop or phone
    • 0:09:50to a large space on campus.
    • 0:09:52We'll invite all of your friends, even family if they're around.
    • 0:09:55And the goal will be simply to have chats like this
    • 0:09:57and present your final project to passersby.
    • 0:09:59There'll be a bit of an incentive model, whereby
    • 0:10:01anyone who chats you up about their project,
    • 0:10:04you can give a little sticker to.
    • 0:10:05And that will enter them into a raffle for fabulous prizes
    • 0:10:08to grease the wheels of conversations as well.
    • 0:10:10And you'll see faculty from across campus join us as well.
    • 0:10:14But ultimately, you walk out of that event with this here CS50 shirt,
    • 0:10:18one like it, so you too, can proudly proclaim that you indeed took CS50.
    • 0:10:23So all that and more to come, resting on finally, those final projects.
    • 0:10:27But how to get there.
    • 0:10:28So here are some general advice that's not necessarily going
    • 0:10:30to be applicable to all final projects.
    • 0:10:32But as we exit CS50 and enter the real world,
    • 0:10:35here are some tips on what you might read, what you might download,
    • 0:10:38sort of starting points so that in answer to the FAQ, what now?
    • 0:10:42So for instance, if you would like to begin
    • 0:10:45to experience on your own Mac or PC more of the programming environment
    • 0:10:49that we provided to you, sort of turnkey style in the cloud using cs50.dev,
    • 0:10:53you can actually install command line tools on your own laptop, desktop,
    • 0:10:57or the like.
    • 0:10:58For instance, Apple has their own.
    • 0:10:59Windows has their own.
    • 0:11:00So you can open a terminal window on your own computer
    • 0:11:03and execute much of the same commands that you've been doing in Linux
    • 0:11:06this whole term.
    • 0:11:07Learning Git, so Git is version control software.
    • 0:11:10And it's very, very popular in industry.
    • 0:11:12And it's a mechanism for saving multiple versions of your files.
    • 0:11:16Now, this is something you might be familiar with if still,
    • 0:11:19even using file names in the real world, like on your Mac or PC--
    • 0:11:23maybe this is resume version 1, resume version 2,
    • 0:11:26resume Monday night version, resume Tuesday, or whatever the case may be.
    • 0:11:30If you're using Google documents, this happens automatically nowadays.
    • 0:11:33But with code, it can happen automatically, but also
    • 0:11:36more methodically using this here tool.
    • 0:11:39And Git is a very popular tool for collaborating with others as well.
    • 0:11:43And you've actually been secretly using it
    • 0:11:45underneath the hood for a lot of CS50's tools.
    • 0:11:47But we've abstracted away some of the details.
    • 0:11:49But Brian, via this video and any number of other references,
    • 0:11:52can peel back that abstraction and show you how to use it more manually.
    • 0:11:55You don't need to use cs50.dev anymore but you are welcome to.
    • 0:11:58You can instead install VS Code onto your own Mac or PC.
    • 0:12:01If you go to this first URL here, it's a free download.
    • 0:12:04It's actually open source.
    • 0:12:05So you can even poke around and see how it, itself is built.
    • 0:12:08And at CS50's own documentation, we have some tips
    • 0:12:11for making it look like CS50's environment even if longer term,
    • 0:12:15you want to cut the cord entirely.
    • 0:12:17What can you now do?
    • 0:12:18Well, many of you for your final projects
    • 0:12:20will typically tackle websites, sort of building on the ideas of problem
    • 0:12:24set 9, CS50 finance and the like, or just generally something dynamic.
    • 0:12:28But if you instead want to host a portfolio, like just your resume, just
    • 0:12:32projects you've worked on and the like, a static websites
    • 0:12:35can be hosted for free via various services.
    • 0:12:38A popular one is this URL here, called GitHub pages.
    • 0:12:41There's another service that offers a free tier called
    • 0:12:43Netlify that can allow you to host your own projects statically for free.
    • 0:12:47But when it comes to more dynamic hosting, you have many more options.
    • 0:12:51And these are just some of the most popular.
    • 0:12:53The first three are some of the biggest cloud providers
    • 0:12:55nowadays, whether it's Amazon or Microsoft Azure or Google services.
    • 0:13:00If you go to this fourth URL here, this is GitHub's education pack,
    • 0:13:03they essentially broker with lots of different companies
    • 0:13:06to give students, specifically, discounts on
    • 0:13:08or free access to a lot of tools.
    • 0:13:10So you might want to sign up for that while you're eligible.
    • 0:13:13And then lastly, here are two other popular third-party, but not
    • 0:13:16free services, but that are very commonly
    • 0:13:18used when you want to host actual web applications.
    • 0:13:20So maybe it's Flask, maybe it's something else, but something
    • 0:13:23that involves some input and output.
    • 0:13:26Questions meanwhile-- so there's just lots of communities.
    • 0:13:29If you want to keep an eye on what's happening in tech,
    • 0:13:32these are just some of the popular options.
    • 0:13:34And undoubtedly, if you have some techie friends,
    • 0:13:36they'll have suggestions as well.
    • 0:13:38But you might find some of these destinations of interest.
    • 0:13:40Of course increasingly, will you just ask questions of software itself,
    • 0:13:44AI, whether it's ChatGPT, GitHub Copilot, or the like.
    • 0:13:50And then classes, we're clearly a little biased here with what's on the screen.
    • 0:13:53So these aren't college classes per se, but freely available OpenCourseWare
    • 0:13:57courses that CS50's team has put together over time.
    • 0:14:00And in a nutshell as you can infer from the suffix of each of these URLs,
    • 0:14:03if you want to learn more about Python, CS50
    • 0:14:05has got a free, open online class for that, or SQL, thanks
    • 0:14:09to Carter, web and AI stuff, thanks to Brian, a games class, thanks to Colton,
    • 0:14:13cybersecurity, which will extend where we leave off today.
    • 0:14:17And then if you're more interested, not so
    • 0:14:19much in coding and going more deeply into software,
    • 0:14:22but want to take a step higher level and focus more on intersections of computer
    • 0:14:28science with business or law or technology,
    • 0:14:30those two are freely available, if you're
    • 0:14:31looking for something to do over January the summer or just to dabble over time.
    • 0:14:35And there's innumerable other free resources
    • 0:14:37from other folks on the internet as well certainly too.
    • 0:14:42All right, so a few invitations and thank yous.
    • 0:14:45So one, after today, after we dive into and out of cybersecurity,
    • 0:14:49please do stay in touch via any of CS50's online communities.
    • 0:14:52As we start to recruit next year's team for teaching fellows, teaching
    • 0:14:55assistants, course assistants, we'll be in touch via email
    • 0:14:58for those opportunities as well.
    • 0:15:01And now some thanks for the group before we then dive into here today's topic.
    • 0:15:04So one, allow me to thank our hosts here for giving us
    • 0:15:08access to such a wonderful, privileged space to just hold classes in,
    • 0:15:12the whole team for Memorial Hall.
    • 0:15:13Our thanks too, to ESS, which is the team that makes everything sound so
    • 0:15:17good in spaces like this with music, mics, and the like, our friends,
    • 0:15:20of course, Wesley down the road at Changsho, where we went most
    • 0:15:23every other Friday this semester.
    • 0:15:25If you've never actually been, or if you're hearing this online,
    • 0:15:28please join our friends at Changsho show on Mass Ave down the road
    • 0:15:31any time you might like.
    • 0:15:32And then especially, CS50's team-- there's quite a few humans
    • 0:15:35operating cameras in the room, both here and way in back, as well as online.
    • 0:15:40My thanks.
    • 0:15:41[APPLAUSE]
    • 0:15:42Thank you to them for making this look and sound so good.
    • 0:15:48And what you don't see is when I do actually screw up,
    • 0:15:50even if we don't fix it in real time, they very kindly
    • 0:15:53help us go back in time, fix things, so that your successors have hopefully,
    • 0:15:56an even improved version as well.
    • 0:15:59And then as well, CS50's own Sophie Anderson,
    • 0:16:03who is the daughter of one of CS50's teaching fellows
    • 0:16:06who lives all the way over in New Zealand, who has wonderfully
    • 0:16:08brought the CS50 duck to life in this animated form.
    • 0:16:12thanks to Sophie, this duck is now everywhere, including most recently,
    • 0:16:16on some T-shirts too.
    • 0:16:17But of course, we have this massive support structure
    • 0:16:20in the form of the team.
    • 0:16:21This is some of our past team members, but who
    • 0:16:23wonderfully via Zoom you'll recall in week seven,
    • 0:16:26showed us how TCP/IP works by passing those envelopes up,
    • 0:16:31down, left, and right.
    • 0:16:32I commented at the time, disclaim, that it actually took us
    • 0:16:35quite a bit of effort to do that.
    • 0:16:36And so I thought I would share as a representative thanks
    • 0:16:39of our whole teaching team, whether it's Carter and Julia and Ozan and Cody
    • 0:16:45and all of C50's team members in Cambridge in New Hey,
    • 0:16:48thought I'd give you a look behind the scenes at how things go indeed,
    • 0:16:52behind the scenes that you don't necessarily see.
    • 0:16:54So let me switch over here and hit play.
    • 0:16:58[VIDEO PLAYBACK]
    • 0:16:58[INAUDIBLE]
    • 0:16:59[INAUDIBLE] Buffering.
    • 0:17:01OK.
    • 0:17:03Josh?
    • 0:17:04Nice.
    • 0:17:06Helen?
    • 0:17:07Oh.
    • 0:17:07[CHUCKLING]
    • 0:17:12[INAUDIBLE] Moni-- no, oh, wait.
    • 0:17:20That was amazing, Josh.
    • 0:17:25Sophie.
    • 0:17:33Amazing.
    • 0:17:35That was perfect.
    • 0:17:37Moni.
    • 0:17:38[LAUGHTER] I think I--
    • 0:17:42[INTERPOSING VOICES]
    • 0:17:44- Over to you, [INAUDIBLE].
    • 0:17:47Guy.
    • 0:17:52That was amazing.
    • 0:17:53Thank you all.
    • 0:17:54- So good.
    • 0:17:54[END PLAYBACK]
    • 0:17:55DAVID MALAN: All right, these outtakes aside,
    • 0:17:57my thanks to the whole teaching team for making this whole class possible.
    • 0:18:00[APPLAUSE]
    • 0:18:03So cybersecurity, this refers to the process
    • 0:18:05of keeping secure our systems, our data, our accounts, and.
    • 0:18:09More and it's something that's going to be increasingly important, as it
    • 0:18:12already is, just because of the sheer omnipresence of technology
    • 0:18:15on our desks, on our laps, in our pockets, and beyond.
    • 0:18:18So exactly what is it?
    • 0:18:19And how can we, as students of computer science over the past many weeks,
    • 0:18:23think about things a little more methodically, a little more carefully,
    • 0:18:27and maybe even put some numbers to the intuition that I think a lot of you
    • 0:18:31probably have when it comes to deciding, is something secure or is it not?
    • 0:18:34So first of all, what does it mean for something to be secure?
    • 0:18:38How might you as citizens of the world now answer that question?
    • 0:18:42What does it mean to be secure?
    • 0:18:43AUDIENCE: Resistant to attack.
    • 0:18:45DAVID MALAN: OK, so resistant to attack, I like that formulation.
    • 0:18:47Other thoughts on what it means to be secure?
    • 0:18:52What does it mean?
    • 0:18:52Yeah.
    • 0:18:53AUDIENCE: You control who has access to it.
    • 0:18:55DAVID MALAN: Yeah, so you control who has access to something.
    • 0:18:58And there's these techniques known as authentication, like logging in,
    • 0:19:01authorization, deciding whether or not that person,
    • 0:19:03once authenticated, should have access to things.
    • 0:19:06And, of course, you and I are very commonly
    • 0:19:08in the habit of using fairly primitive mechanisms still.
    • 0:19:10Although, we'll touch today on some technologies
    • 0:19:13that we'll see all the more of in the weeks and months and years to come.
    • 0:19:16But you and I are pretty much in the habit
    • 0:19:18of relying on passwords for most everything still today.
    • 0:19:21And so we thought we'd begin with exactly this topic
    • 0:19:23to consider just how secure or insecure is this mechanism and why
    • 0:19:27and see if we can't evaluate it a little more
    • 0:19:29methodically so that we can make more than intuitive arguments,
    • 0:19:32but quantitative compelling arguments as well.
    • 0:19:34So unfortunately we humans are not so good at choosing passwords.
    • 0:19:38And every year, accounts are hacked into.
    • 0:19:41Maybe yours, maybe your friends, maybe your family members
    • 0:19:44have experienced this already.
    • 0:19:45And this unfortunately happens to so many people online.
    • 0:19:48But, fortunately, there are security researchers
    • 0:19:50in the world that take a look at attacks once they have happened,
    • 0:19:54particularly when data from attacks, databases, are posted online
    • 0:19:58or on the so-called dark web or the like and downloaded
    • 0:20:01by others for malicious purposes, they can also conversely provide us
    • 0:20:04with some insights as to the behavior of us humans
    • 0:20:07that might give us some insights as to when and why things
    • 0:20:09are getting attacked successfully.
    • 0:20:12So as of last year, here, for instance, according to one measure
    • 0:20:15are the top 10 most popular, a.k.a.
    • 0:20:18worst passwords-- at least according to the data
    • 0:20:21that security researchers have been able to glean--
    • 0:20:24by attacks that have already happened.
    • 0:20:25So the number one password as of last year, according to systems compromised,
    • 0:20:29was 123456.
    • 0:20:33The second most, admin.
    • 0:20:35The third most, 12345678.
    • 0:20:37And thereafter, 123456789, 1234, 12345, password, 123, Aa123456, and then
    • 0:20:511234567890.
    • 0:20:53So you can actually infer--
    • 0:20:54sort of goofy as some of these are-- you can actually infer certain policies
    • 0:20:58from these, right?
    • 0:20:59The fact that we're taking such little effort to choose our password
    • 0:21:03seems to correlate really with probably, what's
    • 0:21:05the minimum length of a password required for systems?
    • 0:21:08And you can see that at worst, some systems
    • 0:21:10require only three digit passwords.
    • 0:21:13And maybe they might require six or eight or nine or even 10.
    • 0:21:17But you can kind of infer corporate or policies from these passwords alone.
    • 0:21:22If you keep going through the list, there's some funnier ones even down
    • 0:21:26the list that are nonetheless enlightening.
    • 0:21:28So, for instance, lower on the list is Iloveyou, no spaces.
    • 0:21:31Sort of adorable, maybe it's meaningful to you.
    • 0:21:34But if you can think of it, so can an adversary,
    • 0:21:37so can some hacker, so much so that it's this popular on these lists.
    • 0:21:41Qwertyuiop, it's not quite English, but its derivative of English keyboards.
    • 0:21:48Anyone?
    • 0:21:49Yeah, so this is, if you look at a US English keyboard,
    • 0:21:51it's just the top row of keys if you just
    • 0:21:53hit them all together left or right to choose your, therefore, password.
    • 0:21:57And then this one, "password," which has an at
    • 0:22:00sign for the A and a zero for the O, which I guess I'm guessing some of you
    • 0:22:05do similar tricks.
    • 0:22:06But this is the thing too, if you think like you're being clever,
    • 0:22:09well, there's a lot of other adversaries,
    • 0:22:11there's a lot of adversaries out there who are just as good at being clever.
    • 0:22:14So even heuristics like this that in the past, to be fair,
    • 0:22:17you might have been taught to do because it confuses
    • 0:22:20adversaries' or hackers' attempts, unfortunately, if you know to do it,
    • 0:22:23so does the adversary.
    • 0:22:25And so your accounts aren't necessarily any more secure as a result.
    • 0:22:29So what are some of our takeaways from this?
    • 0:22:31Well, one, if you have these lists of passwords, all too possible
    • 0:22:36are, for instance, dictionary attacks.
    • 0:22:39Like we literally have published on the internet--
    • 0:22:42and there's a citation in the slides if you're curious--
    • 0:22:44of these most popular passwords in the world.
    • 0:22:46So what's a smart adversary going to do when trying to get into your account?
    • 0:22:49They're not necessarily going to try all possible passwords
    • 0:22:51or try your birthday or things like that.
    • 0:22:53They're just going to start with this top 10 list, this top 100 list.
    • 0:22:56And odds are, statistically, in a room this big,
    • 0:22:58they're probably going to get into at least one person's account.
    • 0:23:02But let's consider maybe a little more academically what we can do about this.
    • 0:23:07And let's start with something simple like the simplest, the most
    • 0:23:10omnipresent device we might all have now is some kind
    • 0:23:12of mobile device like a phone.
    • 0:23:14Generally speaking, Apple and Google and others
    • 0:23:16are requiring of us that we at least have
    • 0:23:18a passcode or at least you're prompted to set it up
    • 0:23:20even if you therefore opt out of it.
    • 0:23:22But most of us probably have a passcode, be it numeric or alphabetic
    • 0:23:27or something else.
    • 0:23:28So what might we take away from that?
    • 0:23:31Well, suppose that you do the bare minimum.
    • 0:23:33And the default for years has generally been having
    • 0:23:35at least four digits in your passcode.
    • 0:23:37Well, what does that mean?
    • 0:23:39Well, how secure is that?
    • 0:23:40How quickly might it be hacked?
    • 0:23:42And, in fact, Carter, would you mind joining me up here?
    • 0:23:44Perhaps we can actually decide together how best to proceed here.
    • 0:23:50If you want to flip over to your other screen there,
    • 0:23:52we're going to ask everyone to go to--
    • 0:23:55I'll pull it up here-- this URL here if you haven't already.
    • 0:23:59And this is going to pull up a polling website that's
    • 0:24:02going to allow you in a moment to answer some multiple choice questions.
    • 0:24:07This is the same URL as earlier if you already logged in.
    • 0:24:10And in just a moment, we're going to ask you a question.
    • 0:24:13And I think, can we show the question before we do this?
    • 0:24:17Here's the first question from Carter here.
    • 0:24:19How long might it take to crack--
    • 0:24:22that is, figure out-- a four-digit passcode on someone's phone,
    • 0:24:26for instance?
    • 0:24:28How long might it take to crack a four-digit passcode?
    • 0:24:33Why don't we go ahead and flip over to see who is typing in what.
    • 0:24:37And we'll see what the scores are already.
    • 0:24:41All right, and it looks like most of you think a few seconds.
    • 0:24:44Some of you think a few minutes, a few hours, a few days.
    • 0:24:47So I'd say most of you are about to be very unpleasantly surprised.
    • 0:24:50In fact, the winner here is indeed going to be a few seconds,
    • 0:24:53but perhaps even faster than that.
    • 0:24:55So, in fact, let me go ahead and do this.
    • 0:24:57Thank you to Carter.
    • 0:24:58Let me flip over and let me introduce you
    • 0:24:59to, unfortunately, what's a very real world problem known as a brute force
    • 0:25:02attack.
    • 0:25:03As the word kind of conjures, if you think
    • 0:25:05to-- back to yesteryear when there was some kind of battering ram trying
    • 0:25:08to brute force their way into a castle door,
    • 0:25:10it just meant trying to hammer the heck out of a system.
    • 0:25:13A castle, in that case, to get into the destination.
    • 0:25:17Digitally though, this might mean being a little more clever.
    • 0:25:20We all know how to write code in a bunch of different languages now.
    • 0:25:23You could maybe open up a text editor, write a Python program to try all
    • 0:25:28possible four-digit codes from 0000 to 9999 in order to figure out exactly,
    • 0:25:35how long does it actually take?
    • 0:25:37So let's first consider this.
    • 0:25:39Let me ask the next question.
    • 0:25:41How many four-digit passcodes are there?
    • 0:25:43Carter, if you wouldn't mind joining me and maybe just staying up
    • 0:25:45with me here to run our second question at this same URL.
    • 0:25:49How many four-digit passcodes are there in the world?
    • 0:25:53On your phone or laptop, you should now see the second question.
    • 0:25:57And the answers include 4, 40, 9,999, 10,000, or it's OK to be unsure.
    • 0:26:05Let's go ahead and flip over to the results.
    • 0:26:07And it looks like most of you think 10,000.
    • 0:26:09And, indeed, that is the case.
    • 0:26:10Because if I kind of led you with 0000 to 9999, that's 10,000 possibilities.
    • 0:26:16So that is, in fact, a lot.
    • 0:26:17But most of you thought it'd take maybe a few seconds to actually brute force
    • 0:26:21your way into that.
    • 0:26:22Let's consider how we might measure how long that actually takes.
    • 0:26:26So thank you.
    • 0:26:26So in the world of a four-digit passcode-- and they
    • 0:26:29are, indeed, digits, decimal digits from 0 to 9--
    • 0:26:32another way to think about it is there's 10 possibilities for the first digit,
    • 0:26:3510 for the next, 10 to the 10.
    • 0:26:37So that really gives us 10 times itself four times or 10,000 in total.
    • 0:26:42But how long does that actually take?
    • 0:26:44Well, let me go ahead and do this.
    • 0:26:45I'm going to go ahead and open up on my Mac here, not even--
    • 0:26:49not even Codespaces or cs50.dev today.
    • 0:26:52I'm going to open up VS Code itself.
    • 0:26:54So before class, I went ahead and installed VS Code on my own Mac here.
    • 0:26:58It looks almost the same as Codespaces, though the windows
    • 0:27:01might look a little different and the menus as well.
    • 0:27:03And I've gone ahead here and begun a file called crack.py.
    • 0:27:06To crack something means to break into it,
    • 0:27:09to figure out in this case what the passcode actually is.
    • 0:27:12Well, how might I write some code to try all 10,000 possible passcodes?
    • 0:27:16And, heck, even though this isn't quite going
    • 0:27:19to be like hacking into my actual phone, I
    • 0:27:21bet I could find a USB or a lightning cable, connect the two devices,
    • 0:27:24and maybe send all of these passcodes to my device trying to brute force
    • 0:27:28my way in.
    • 0:27:29And that's indeed how a hacker might go about doing this
    • 0:27:31if the manufacturer doesn't protect against that.
    • 0:27:34So here's some code.
    • 0:27:35Let me go ahead and do this.
    • 0:27:36From string, import digits.
    • 0:27:38This isn't strictly necessary.
    • 0:27:40But in Python, there is a string library from which
    • 0:27:42you can get all of the decimal digits just so I don't
    • 0:27:45have to manually type out 0 through 9.
    • 0:27:46But that's just a minor optimization.
    • 0:27:48But there's another library called itertools,
    • 0:27:51tools related to iteration, doing things in like a looping fashion, where
    • 0:27:55I can import a cross product function, a function that's
    • 0:27:58going to allow me to combine like all numbers with all numbers
    • 0:28:01again and again and again for the length of the passcode.
    • 0:28:03Now I can do a simple Python for loop like this.
    • 0:28:07For each passcode in the cross product of those 10 digits repeated four times.
    • 0:28:14In other words, this is just a programmatic Pythonic way
    • 0:28:18to implement the idea of combining all 10 digits with itself
    • 0:28:21four times in a loop in this fashion.
    • 0:28:24And just so we can visualize this, let's just go ahead
    • 0:28:26and print out the passcode.
    • 0:28:28But if I did have a lightning cable or a USB cable, I wouldn't print it.
    • 0:28:31I would maybe send it through the cable to the device
    • 0:28:33to try to get through the passcode screen.
    • 0:28:35So we can revisit now the question of how long
    • 0:28:38might it take to get into this device.
    • 0:28:40Well, let's just try this.
    • 0:28:41Python of crack.py.
    • 0:28:43And assume, again, it's connected via cable.
    • 0:28:45So we'll see how long this program takes to run and break into this here phone.
    • 0:28:49Done.
    • 0:28:50So that's all it took for 10,000 iterations.
    • 0:28:53And this is on a Mac that's not even the fastest one out there.
    • 0:28:56You could imagine doing this even faster.
    • 0:28:58So that's actually not necessarily all the best for our security.
    • 0:29:02So what could we do instead of 10 digits?
    • 0:29:04Well, most of you have probably upgraded a lot of your passwords
    • 0:29:07to maybe being alphabetical instead.
    • 0:29:10So what if I instead were to ask the question-- and Carter, if you
    • 0:29:13want to rejoin me here in a second-- what if I instead were to consider
    • 0:29:17maybe four-letter passcodes?
    • 0:29:19So now we have A through Z four times.
    • 0:29:23And maybe we'll throw into the mix uppercase and--
    • 0:29:25well, let's just keep it four letters.
    • 0:29:27Let's just go ahead and do maybe uppercase and lowercase,
    • 0:29:31so 52 possibilities.
    • 0:29:34This is going to give us 52 times 52 times 52 times 52.
    • 0:29:39And anyone want to ballpark the math here,
    • 0:29:41how many possible four-letter passcodes are there, roughly?
    • 0:29:487 million, yeah, so roughly 7 million, which is way bigger than 10,000.
    • 0:29:53So, oh, I spoiled this, didn't I?
    • 0:29:57Can you flip over?
    • 0:29:58So how many four-letter passcodes are there?
    • 0:30:02It seems that most of you, 93% of you, in fact, got the answer right.
    • 0:30:07Those of you who are changing your answer-- there
    • 0:30:09we go, no, definitely not that.
    • 0:30:12So, anyhow, I screwed up.
    • 0:30:13Order of operations matters in computing and, indeed, including lectures.
    • 0:30:16So 7 million, so the segue I wanted to make
    • 0:30:19is, OK, how long does that actually take to implement in code?
    • 0:30:22Well, let me just tweak our code here a little bit.
    • 0:30:24Let me go ahead and go back into the VS Code on my Mac in which I
    • 0:30:30had the same code as before.
    • 0:30:32So let me shrink my terminal window, go back to the code from which I began.
    • 0:30:36And let's just actually make a simple change.
    • 0:30:38Let me go ahead and simply change digits to something called ASCII letters.
    • 0:30:42And this too is just a time saving technique.
    • 0:30:45So I don't have to type out A through Z and uppercase and lowercase like 52
    • 0:30:48total times.
    • 0:30:49And so I'm going to change digits to ASCII letters.
    • 0:30:52And we'll get a quantitative sense of how long this takes.
    • 0:30:55So Python of crack.py, here's how long it takes
    • 0:30:58to go through 7 million possibilities.
    • 0:31:01All right, clearly slower because we haven't seen the end of the list yet.
    • 0:31:05And you can see we're going through all of the lowercase letters here.
    • 0:31:08We're about to hit Z. But now we're going through the uppercase letters.
    • 0:31:11So it looks like the answer this time is going to be a few seconds, indeed.
    • 0:31:14But definitely less than a minute would seem, at least
    • 0:31:17on this particular computer.
    • 0:31:18So odds are if I'm the adversary and I've
    • 0:31:20plugged this phone into someone's device-- maybe
    • 0:31:22I'm not here in a lecture, but in Starbucks or an airport
    • 0:31:24or anywhere where I have physical opportunity to grab that device
    • 0:31:27and plug a cable in-- it's not going to take long to hack into that device
    • 0:31:31either.
    • 0:31:31So what might be better than just digits and letters from the real world?
    • 0:31:35So add in some punctuation, which like almost every website
    • 0:31:39requires that we do.
    • 0:31:40Well, if we want to add punctuation into the mix, if I can get this segue
    • 0:31:44correct so that we can now ask Carter one last time,
    • 0:31:48how many four-character passcodes are possible where a character is
    • 0:31:52an uppercase or lowercase letter or a decimal digit or a punctuation symbol?
    • 0:31:57If you go to your device now, you'll see--
    • 0:32:00if we want to flip over to the screen--
    • 0:32:02these possibilities.
    • 0:32:03There's a million, maybe, a billion, a trillion, a quadrillion,
    • 0:32:08or a quintillion when it comes to a-- oh, wrong question.
    • 0:32:12Wow, we're new here, OK.
    • 0:32:14OK, we're going to escalate things here.
    • 0:32:16How many eight-character passcodes are possible?
    • 0:32:18We're going to make things more secure, even though I said four.
    • 0:32:23We're now making it more secure to eight.
    • 0:32:26All right, you want to flip over to the chart?
    • 0:32:29All right, so it looks like most of you are now
    • 0:32:31erring on the side of quintillion or quadrillion.
    • 0:32:341% of you still said million, even though there's definitely more
    • 0:32:37than there were a moment ago.
    • 0:32:39But that's OK.
    • 0:32:39So quadrillion-- quintillion is still winning.
    • 0:32:42And I think if we go and reveal this, with the math,
    • 0:32:45you should be doing is 94 to the 4th power.
    • 0:32:48Because there's 26 plus 26 plus 10 plus some more digits,
    • 0:32:53some punctuation digits in there as well.
    • 0:32:55So it's actually, oh, this is the other example, isn't it?
    • 0:33:00This is embarrassing.
    • 0:33:01All right, we had a good run in the past nine weeks instead.
    • 0:33:04All right, so if you were curious as to how many four-character passwords are
    • 0:33:08possible, it's 78 million.
    • 0:33:10But that's not the question at hand.
    • 0:33:11The question at hand was, how many eight character passcodes are there?
    • 0:33:15And in this case, the math you would be doing
    • 0:33:17is 94 to the 8th power, which is a really big number.
    • 0:33:21And, in fact, it's this number here, which
    • 0:33:23is roughly 6 quadrillion possibilities.
    • 0:33:27Now, I could go about actually doing this in code here.
    • 0:33:30So let me actually, for a final flourish,
    • 0:33:33let me open up VS Code one last time here.
    • 0:33:35And in VS Code, I'm going to go ahead and shrink my terminal window,
    • 0:33:39go back into the code, and I'm going to import not just ASCII letters, not just
    • 0:33:43digits, but punctuation as well, which is
    • 0:33:45going to give me like 32 punctuation symbols
    • 0:33:48from a typical US English keyboard.
    • 0:33:49And I'm going to go ahead and just concatenate them all together in one
    • 0:33:52big list by using the plus operator in Python
    • 0:33:55to plus in both digits and punctuation.
    • 0:33:58And I'm going to change the 4 to an 8.
    • 0:34:01So this now, it's what four actual lines of code
    • 0:34:04is, all it takes for an adversary to whip up some code,
    • 0:34:06find a cable as step two, and hack into a phone that
    • 0:34:09even has eight-character passcodes.
    • 0:34:11Let me enlarge in my terminal window here, run
    • 0:34:15for a final time Python of crack.py.
    • 0:34:17And this I'll actually leave running for some time.
    • 0:34:20Because you can get already sort of a palpable feel of how much slower it
    • 0:34:25is-- because these characters clearly haven't moved--
    • 0:34:27how long it's going to take.
    • 0:34:28We might actually do-- need to do a bit more math.
    • 0:34:31Because doing just four-digit passcodes was super fast.
    • 0:34:33Doing four-letter passcodes was slower, but still under a minute.
    • 0:34:37We'll see maybe in time how long this actually runs for.
    • 0:34:41But this clearly seems to be better, at least for some definition of better.
    • 0:34:46But it should hopefully not be that easy to hack into a system.
    • 0:34:51What does your own device probably do to defend against that brute force attack?
    • 0:34:57Yeah.
    • 0:34:58AUDIENCE: Gives you a limited number of tries.
    • 0:34:59DAVID MALAN: Yeah, so it gives you a limited number of tries.
    • 0:35:01So odds are, at least once in your life, you've somehow locked yourself out
    • 0:35:05of a device, typically after typing your passcode more than 10 times
    • 0:35:09or 10 attempts or maybe it's your siblings or your roommate's phone
    • 0:35:12that you realize this is a feature of iPhones and Android devices as well.
    • 0:35:16But here's a screenshot of what an iPhone might
    • 0:35:18do if you do try to input the wrong passcode maybe 10 or so times.
    • 0:35:23Notice that it's really telling you to try again in one minute.
    • 0:35:26So this isn't fundamentally changing what the adversary can do.
    • 0:35:30The adversary can absolutely use those same four lines of code with a cable
    • 0:35:33and try to hack into your device.
    • 0:35:35But what has this just done?
    • 0:35:36It's significantly increased the cost to the adversary,
    • 0:35:40where the cost might be measured in sheer number amount of time--
    • 0:35:43like minutes, seconds, hours, days, or beyond.
    • 0:35:46Maybe it's increased the cost in the sense of risk.
    • 0:35:48Why?
    • 0:35:49Because if this were like a movie incarnation of this
    • 0:35:51and the adversary has just plugged into the phone
    • 0:35:53and is kind of creepily looking around until you come back,
    • 0:35:56it's going to take way too long for them to safely get away with that,
    • 0:36:00assuming your passcode is not 123456, it's
    • 0:36:03somewhere in the middle of that massive search space.
    • 0:36:05So this just kind of fundamentally raises the bar to the adversary.
    • 0:36:09And that's one of the biggest takeaways of cybersecurity in general.
    • 0:36:12It's completely naive to think in terms of absolute security
    • 0:36:16or to even say a sentence like "my website is secure" or even
    • 0:36:19"my home is physically secure."
    • 0:36:21Why?
    • 0:36:21Well, for a couple of reasons, like, one, an adversary
    • 0:36:24with enough time, energy, motivation, or resources
    • 0:36:27can surely get into most any system and can surely get into most any home.
    • 0:36:31But the other thing to consider, unfortunately,
    • 0:36:34that if we're the good people in this story and the adversaries
    • 0:36:36are the bad people, you and I rather have to be perfect.
    • 0:36:40In the physical world, we have to lock every door, every window.
    • 0:36:44Because if we mess up just one spot, the adversary can get in.
    • 0:36:48And so where there's sort of this imbalance.
    • 0:36:50The adversary just has to find the window that's
    • 0:36:52ajar to get into your physical home.
    • 0:36:54The adversary just needs to find one user who's
    • 0:36:56got a really bad password to somehow get into that system.
    • 0:36:59And so cybersecurity is hard.
    • 0:37:01And so what we'll see today really are techniques
    • 0:37:04that can let you create a gauntlet of defenses-- so not just one,
    • 0:37:07but maybe two, maybe three.
    • 0:37:09And even if the adversary gets in, another tenant of cybersecurity
    • 0:37:12is at least, let's have mechanisms in place that detect
    • 0:37:15the adversary, some kind of monitoring, automatic emails.
    • 0:37:19You can increasingly see this already in the real world.
    • 0:37:21If you log into your Instagram account from a different city or state
    • 0:37:25suddenly because maybe you're traveling, you
    • 0:37:27will-- if you've opted into settings like these-- often
    • 0:37:29get a notification or an email saying, hey,
    • 0:37:32you seems to have logged in from Palo Alto rather than Cambridge.
    • 0:37:35Is this, in fact, you?
    • 0:37:37So even though we might not be able to keep the adversary out,
    • 0:37:40let's at least minimize the window of opportunity or damage
    • 0:37:43by letting humans like us know that something's been compromised.
    • 0:37:46Of course, there is a downside here.
    • 0:37:48And this is another theme of cybersecurity.
    • 0:37:50Every time you improve something, you've got to pay a price.
    • 0:37:54There's going to be a tradeoff.
    • 0:37:56And we've seen this with time and space and money and other such resources
    • 0:38:00when it comes to designing systems already.
    • 0:38:03What's the downside of this mechanism?
    • 0:38:06Why is this perhaps a bad thing or what's the downside to you,
    • 0:38:09the good person in the story?
    • 0:38:11Yeah.
    • 0:38:12AUDIENCE: [INAUDIBLE]
    • 0:38:14DAVID MALAN: Yeah, if you've just forgotten your passcode,
    • 0:38:17it's going to be more difficult for you to log in.
    • 0:38:19Or maybe you just really need to get into your phone now
    • 0:38:23and you don't really want to wait a minute.
    • 0:38:25And if you, worse, if you keep trying, sometimes it'll
    • 0:38:27change to two minutes, five minutes, one hour.
    • 0:38:30It'll increase exponentially.
    • 0:38:32Why?
    • 0:38:32Because Apple and Google figure that, they don't necessarily
    • 0:38:35know what the right cutoff is.
    • 0:38:38Maybe it's 10, maybe it's fewer, maybe it's more.
    • 0:38:40But at some point, it is much more likely
    • 0:38:43that this is a hacker trying to get in than it is for getting your passcode.
    • 0:38:46But in the corporate world, it can be even worse.
    • 0:38:48There's a feature that lets phones essentially self-destruct whereby
    • 0:38:51rather than just waiting you wait a minute,
    • 0:38:53it will wipe the device, more dramatically.
    • 0:38:55The presumption being that, no, no, no, no, no, if this is a corporate phone,
    • 0:38:59let's lock it down further so that it is an adversary,
    • 0:39:01the data is gone after 10 failed attempts.
    • 0:39:04But there's other mechanisms as well.
    • 0:39:07In addition to logging into phones via passcodes,
    • 0:39:10there's also websites like Gmail, for instance.
    • 0:39:12And it's very common, therefore, to log in to websites like these.
    • 0:39:16And odds are, statistically, a lot of you
    • 0:39:18are in the habit of reusing passwords.
    • 0:39:21Like, no, don't nod if you are.
    • 0:39:23We have cameras everywhere.
    • 0:39:24But maybe you're in the habit of reusing it.
    • 0:39:26Why?
    • 0:39:27Because it's hard to remember really big long cryptic passwords.
    • 0:39:31So mathematically, there's surely an advantage there.
    • 0:39:33Why?
    • 0:39:33Because it just makes it so much harder, more time-consuming,
    • 0:39:36more risky for an adversary to get in.
    • 0:39:37But the other tradeoff is like, my God, I just can't even
    • 0:39:40remember most of my passwords as a result
    • 0:39:42unless I reuse the one good password I thought of and memorized already
    • 0:39:47or maybe I write it down on a post-it note on my monitor,
    • 0:39:49as all too often happens in corporate workplaces.
    • 0:39:51Or maybe you're being clever and in your top right drawer,
    • 0:39:54you've got a printout of all of your accounts.
    • 0:39:56Well, if you do, like ha-ha, so do a lot of other people.
    • 0:39:58Or maybe it's a little more secure than that,
    • 0:40:00but there are sociological side effects of these technological policies that
    • 0:40:05really until recent years were maybe underappreciated.
    • 0:40:07The academics, the IT administrators were mandating policies
    • 0:40:11that you and I as human users were not necessarily behaving properly
    • 0:40:15in the face of.
    • 0:40:16So nowadays, there are things called password managers.
    • 0:40:19And a password manager is just a piece of software on Macs,
    • 0:40:22on PCs, on phones that manage your passwords for you.
    • 0:40:25What this means specifically is when you go
    • 0:40:27to a website for the very first time, you, the human,
    • 0:40:30don't need to choose your password anymore.
    • 0:40:32You instead click a button or use some keyboard shortcut.
    • 0:40:35And the software generates a really long cryptic password for you
    • 0:40:39that's not even eight characters.
    • 0:40:41It might be 16 or 32 characters, can be even bigger than that, but with lots
    • 0:40:45of randomness.
    • 0:40:46Definitely not going to be on that top 10 or that top 100 list.
    • 0:40:49The software thereafter remembers that password
    • 0:40:52for you and even your username, whether it's your email address or something
    • 0:40:55else.
    • 0:40:56And it saves it onto your Mac or your phone or your PC's disk or hard drive.
    • 0:41:00The next time you visit that same website, what you can do
    • 0:41:03is via menu or, better yet, a keyboard shortcut, log into the website
    • 0:41:07without even remembering or even knowing your password.
    • 0:41:10I mean, to this day, I'll tell you, I don't even
    • 0:41:12know anymore 99% of my own passwords.
    • 0:41:15Rather, I rely on software like this to do the heavy lifting for me.
    • 0:41:20But there's an obvious downside here, which
    • 0:41:23might be what if you're doing this?
    • 0:41:26Yeah.
    • 0:41:26AUDIENCE: [INAUDIBLE]
    • 0:41:28DAVID MALAN: Right, so what if they find out the one password
    • 0:41:31that's protecting this software?
    • 0:41:33Because unstated by me up until now is that this password manager itself
    • 0:41:37has a primary password that protects all of those other eggs in the one basket,
    • 0:41:42so to speak.
    • 0:41:42And my one primary password for my own password manager,
    • 0:41:46it is really long and hard to guess.
    • 0:41:48And the odds that anyone's going to guess
    • 0:41:49are just so low that I'm comfortable with that
    • 0:41:52being the one really difficult thing that I've committed to my memory.
    • 0:41:55But the problem is if someone does figure it out nonetheless somehow
    • 0:41:59or, worse, I forget what it is.
    • 0:42:01Now, I've not lost access to one account, but all of my accounts.
    • 0:42:04Now, that might be too high of a price to pay.
    • 0:42:06But, again, if you're in the habit of choosing easy passwords like being
    • 0:42:09on that top 10 list, reusing passwords, it's probably a net
    • 0:42:13positive to incur this single risk versus the many risks you're
    • 0:42:18incurring across the board with all of these other sites.
    • 0:42:21As for what you can use, increasingly our operating systems
    • 0:42:24come with support for this, be it in the Apple world, Google, Microsoft world,
    • 0:42:28or the like.
    • 0:42:28There's third party software you can pay for and download.
    • 0:42:31But even then, I would beware.
    • 0:42:32And I would ask friends whose opinion you trust or do
    • 0:42:34some googling for reviews and the like.
    • 0:42:36All too often in the software world have password managers
    • 0:42:41been determined to be buggy themselves.
    • 0:42:44I mean, you've seen in weeks of CS50 how easy it is to introduce bugs.
    • 0:42:48And even the best of programmers still introduce bugs to software.
    • 0:42:51So you're also trusting that the companies making this password
    • 0:42:55management software is really good at it.
    • 0:42:57And that's not always the case.
    • 0:42:59So beware there too.
    • 0:42:59But we'll also focus today on some of the fundamentals
    • 0:43:02that these companies can be using to better protect your data as well.
    • 0:43:05But there's another mechanism, which odds are you're in the habit of using.
    • 0:43:09Two-factor authentication, like most of us
    • 0:43:11probably have to use this for some of your accounts--
    • 0:43:14your Harvard account, your Yale account, maybe your bank accounts, or the like.
    • 0:43:17So what is two-factor authentication in a nutshell?
    • 0:43:21Yeah.
    • 0:43:22AUDIENCE: [INAUDIBLE]
    • 0:43:25DAVID MALAN: Yeah, you get a second factor
    • 0:43:26that you have to provide to the website or application
    • 0:43:29to prove that it's you like a text to your phone
    • 0:43:31or maybe it's an actual application that gets push notifications or the like.
    • 0:43:34Maybe in the corporate world, it's actually
    • 0:43:36a tiny little device with a screen on it that's on your keychain or the like.
    • 0:43:40Maybe it's actually a USB dongle that you have to plug into your work laptop.
    • 0:43:43In short, it's some second factor.
    • 0:43:45And by factor, I mean something technical.
    • 0:43:47It's not just a second password, which would be one factor.
    • 0:43:50It's a second fundamentally different factor.
    • 0:43:52So generally speaking in the world of two-factor authentication or 2FA or MFA
    • 0:43:57is the generalization as multi-factor authentication,
    • 0:44:00you have not just a password, which is something you know,
    • 0:44:03the second factor is usually something you have--
    • 0:44:06whether it's your phone or that application or the keychain.
    • 0:44:09It might also be biometrics like your fingerprints, your retinas,
    • 0:44:12or something else physically about you.
    • 0:44:14But it's something that significantly decreases the probability
    • 0:44:18that some adversary is going to get into that account.
    • 0:44:20Why?
    • 0:44:20Because right now, if you've only got a username and password,
    • 0:44:23your adversaries are literally every human in the world
    • 0:44:26with an internet connection, arguably.
    • 0:44:28But as soon as you introduce 2FA, now it's
    • 0:44:30only people on campus or, more narrowly, only the people in Starbucks
    • 0:44:34at that moment who might physically have access
    • 0:44:36to your person and your second factor, in this case.
    • 0:44:40More technically, what those technologies do is they send you
    • 0:44:43a one-time passcode, which is further secure because once it's used,
    • 0:44:47there's hopefully some database that remembers that it has been used
    • 0:44:50and cannot be used again.
    • 0:44:51So an adversary can't like sniff the airwaves and replay
    • 0:44:54that passcode the next time they, indeed, expire,
    • 0:44:57which adds some additional defense.
    • 0:44:58And you might type it into a phone or maybe a web app that
    • 0:45:02looks a little something like this.
    • 0:45:04So passwords thus far, some defenses, therefore, any questions on this
    • 0:45:10here mechanism?
    • 0:45:13No?
    • 0:45:13All right, well, let's consider this.
    • 0:45:15Odds are, with some frequency, you forget these passwords, especially
    • 0:45:19if you're not using a password manager.
    • 0:45:20And so you go to Gmail and you actually have
    • 0:45:22to click a link like this, Forgot Password.
    • 0:45:24And then it typically emails you to initiate
    • 0:45:28a process of resetting that password.
    • 0:45:30But if you can recall, has anyone ever clicked a link like that
    • 0:45:35and then got an email with your password in the email?
    • 0:45:39Maybe if you ever see this in the wild, that
    • 0:45:42is to say in the real world, that is horrible, horrible design.
    • 0:45:45Why?
    • 0:45:45Because well-designed websites, not unlike CS50 Finance,
    • 0:45:49which had a users table, should not be storing username-- rather,
    • 0:45:53should not be storing passwords in the clear, as it actually is.
    • 0:45:59It should somehow be obfuscated so that even
    • 0:46:02if your database from CS50 Finance or Google's database
    • 0:46:04is hacked and compromised and sold on the web,
    • 0:46:08it should not be as simple as doing like select star
    • 0:46:10from Account semicolon to see what your actual passwords are.
    • 0:46:14And the mechanism that well-designed websites use
    • 0:46:17is actually a primitive back from like week 5 when we
    • 0:46:20talked about hashing and hash tables.
    • 0:46:22This time, we're using it for slightly different purposes.
    • 0:46:24So in the world of passwords, on the server side, there's often a database
    • 0:46:30or maybe, more simply, a text file somewhere on the server
    • 0:46:32that just associates usernames with passwords.
    • 0:46:35So to keep things simple, if there's at least two users like Alice and Bob,
    • 0:46:38Alice's password is maybe apple.
    • 0:46:40Bob's password is maybe banana, just to keep the mnemonics kind of simple.
    • 0:46:43If though that were the case on the server
    • 0:46:46and that server is compromised, whoever the hacker now
    • 0:46:49has access to every username and every password, which in and of itself
    • 0:46:53might not be a huge deal because maybe the server administrators can just
    • 0:46:57disable all of the accounts, make everyone change their password,
    • 0:47:00and move on.
    • 0:47:01But there's also this attack known as password stuffing, which
    • 0:47:05is a weirdly technical term, which means when you compromise one database,
    • 0:47:08you know what?
    • 0:47:09Take advantage of the naivety of a lot of us users.
    • 0:47:12Try the compromised Apple password, the banana
    • 0:47:15password not on the compromised website, but other websites
    • 0:47:18that you and I might have access to, the presumption
    • 0:47:21being that some of us in this room are using
    • 0:47:23the same passwords in multiple places.
    • 0:47:25So it's bad if your password is compromised on one server
    • 0:47:28because, by transitivity, so can all of your other accounts be compromised.
    • 0:47:32So in the world of hashing, this was the picture
    • 0:47:34we drew some time ago, we can apply this same logic whereby, mathematically,
    • 0:47:39a hash function is like some function F and the input is X
    • 0:47:42and the output or the range is F of X. That
    • 0:47:44was sort of the fancy way of describing mathematically
    • 0:47:46hashing as a process weeks ago.
    • 0:47:48But here, at a simpler level, the input to this process
    • 0:47:51is going to be your actual password.
    • 0:47:53The output is going to be a hash value, which in week 5
    • 0:47:56was something simple generally like a number--
    • 0:47:581 or 2 or 3 based on the first letter.
    • 0:48:01That's not going to be quite as naive an approach as we
    • 0:48:04take in the password world.
    • 0:48:05It's going to look a little more cryptic.
    • 0:48:07So Apple weeks ago might have just been 1, banana might have been 3.
    • 0:48:11But now let me propose that in the world of real world system design, what
    • 0:48:15the database people should actually store
    • 0:48:18is not apple, but rather this cryptic value.
    • 0:48:21And you can think of this as sort of random, but it's not random.
    • 0:48:23Because it is the result of an algorithm, some mathematical function
    • 0:48:26that someone implemented and smart people evaluated and said,
    • 0:48:29yes, this seems to be secure, secure in the sense
    • 0:48:32that this hash function is meant to be one way.
    • 0:48:34So this is not encryption, a la Caesar Cipher from weeks
    • 0:48:37ago whereby you could just add 1 to encrypt and subtract 1 to decrypt.
    • 0:48:42This is one way in the sense that given this value,
    • 0:48:44it should be pretty much impossible mathematically to reverse the process
    • 0:48:49and figure out that the user's password was originally apple.
    • 0:48:53Meanwhile banana, back in week 5 for simplicity, for hashing into a table,
    • 0:48:57we might have had a simple output of 2, since B
    • 0:48:59is the second letter of the English alphabet.
    • 0:49:01But now the hash value of banana, thanks to a fancier mathematical function,
    • 0:49:05is actually going to be something more cryptic like this.
    • 0:49:08And so what the server really does is store not apple and banana, but rather
    • 0:49:12those two seemingly cryptic values.
    • 0:49:15And then when the human, be it Alice or Bob,
    • 0:49:19logs in to a web form with their actual username and password, like Alice,
    • 0:49:24apple, Bob, banana, the website no longer even
    • 0:49:28knows that Alice's password is apple and that Bob's is banana.
    • 0:49:32But that's OK.
    • 0:49:33Because so long as the server uses the same code
    • 0:49:36as it was using when these folks registered for accounts,
    • 0:49:40Alice can type in apple, hit Enter, send it via HTTP to the server.
    • 0:49:44The server can run that same hash function on A-P-P-L-E.
    • 0:49:47And if the value matches, it can conclude with high probability, yes,
    • 0:49:51this is in fact, the original Alice or this, in fact, is the original Bob.
    • 0:49:55So the server never saves the password, but it does use the same hash function
    • 0:50:00to compare those same hash values again and again whenever these folks log in
    • 0:50:05again and again.
    • 0:50:06So, in reality, here's a simple one-way hash for both Alice's
    • 0:50:11and Bob's passwords in the real world.
    • 0:50:13It's even longer, this is to say, than what I
    • 0:50:15used as shorter examples a moment ago.
    • 0:50:17But there is a corner case here.
    • 0:50:19Suppose that an adversary is smart and has some free time
    • 0:50:23and isn't necessarily interested in getting into someone's account
    • 0:50:26right now, but wants to do a bit of prework
    • 0:50:28to decrease the future cost of getting into someone's account.
    • 0:50:31There is a technical term known as a rainbow table,
    • 0:50:34which is essentially like a dictionary in the Python sense or the SQL sense,
    • 0:50:38whereby in advance an adversary could just try hashing all of the fruits
    • 0:50:43of the world or, really, all of the English words of the world or, rather,
    • 0:50:47all possible four-digit, four-character, eight-character passcodes in advance
    • 0:50:51and just store them in two columns--
    • 0:50:53the password, like 0000 or apple or banana,
    • 0:50:57and then just store in advance the hash values.
    • 0:50:59So the adversary could effectively reverse engineer the hash
    • 0:51:04by just looking at a hash, comparing it against its massive database of hashes,
    • 0:51:09and figuring out what password originally correspond to that.
    • 0:51:14Why then is this still relatively safe?
    • 0:51:17Rainbow tables are concerning.
    • 0:51:19But they don't defeat passwords altogether.
    • 0:51:23Why might that be?
    • 0:51:26Yeah.
    • 0:51:27AUDIENCE: [INAUDIBLE]
    • 0:51:31DAVID MALAN: OK, so the adversary might not
    • 0:51:33know exactly what hash function the company is using.
    • 0:51:35Generally speaking, you would not want to necessarily keep that private.
    • 0:51:39That would be considered security through obscurity.
    • 0:51:41And all it takes is like one bad actor to tell the adversary what
    • 0:51:45hash function is being used.
    • 0:51:47And then that would put your security more at risk.
    • 0:51:49So generally in the security world, openness
    • 0:51:51when it comes to the algorithms in process
    • 0:51:53is generally considered best practice.
    • 0:51:55And the reality is, there's a few popular hash functions out there
    • 0:51:58that any company should be using.
    • 0:52:00And so it's not really keeping a secret anyway.
    • 0:52:03But other thoughts?
    • 0:52:05Why is this rainbow table not such a concern?
    • 0:52:07AUDIENCE: It takes a lot longer for the [INAUDIBLE]..
    • 0:52:09DAVID MALAN: It takes a lot longer for the adversary
    • 0:52:12to access that information because this table could get long.
    • 0:52:15And even more along those lines-- anyone want to push a little harder?
    • 0:52:18This doesn't necessarily put all of our passwords at risk.
    • 0:52:22It easily puts our four-digit passcodes at risk.
    • 0:52:25Why?
    • 0:52:25Because this table, this dictionary would have, what, 10,000 rows?
    • 0:52:28And we've seen that you can search that kind of like that
    • 0:52:30or even regenerate all of the possible values.
    • 0:52:33But once you get to eight-character passcodes,
    • 0:52:36I said it was 4 quadrillion possibilities.
    • 0:52:38That's a crazy big dictionary in Python or crazy big list
    • 0:52:42of some sort in Python.
    • 0:52:43That's just way more RAM or memory than a typical adversary is going to have.
    • 0:52:48Now, maybe if it's a particularly resourced adversary like a government,
    • 0:52:51a state more generally, maybe they do have supercomputers
    • 0:52:54that can fit that much information.
    • 0:52:55But, fine, then use a 16-character passcode
    • 0:52:58and make it an unpronounceable long search space
    • 0:53:01that's way bigger than 4 quadrillion.
    • 0:53:02So it's a threat, but only if you're on that horrible top 10 list or top 100
    • 0:53:07or short passcode list that we've discussed thus far.
    • 0:53:11So here's though a related threat that's just worth knowing about.
    • 0:53:14What's problematic here?
    • 0:53:15If we introduce two more users, Carol and Charlie,
    • 0:53:18and just for the semantics of it, whose password happened to be cherry.
    • 0:53:23What if they both happened to have the same password and this database
    • 0:53:28is compromised?
    • 0:53:28Some hacker gets in.
    • 0:53:29And just to be clear, we wouldn't be storing apple, banana, cherry, cherry.
    • 0:53:33We'd still be storing, according to this story, these hashes.
    • 0:53:37But why is this still concerning?
    • 0:53:40AUDIENCE: [INAUDIBLE]
    • 0:53:44DAVID MALAN: Exactly.
    • 0:53:45If you figure out just one of them, now you've got the other.
    • 0:53:47And this is, in some sense, just leaking information, right?
    • 0:53:50I don't maybe at a glance what I could do with this information.
    • 0:53:53But if Carol and Charlie have the same password, you know what?
    • 0:53:56I bet they have the same password on other systems as well.
    • 0:53:59You're leaking information that just does no good for anyone.
    • 0:54:02So how can we avoid that?
    • 0:54:04Well, we probably don't want to force Carol or Charlie to change
    • 0:54:07their password, especially when they're registering.
    • 0:54:09You definitely don't want to say, sorry, someone's already using that password,
    • 0:54:12you can't use it as well.
    • 0:54:13Because that too would leak information.
    • 0:54:15But there's this technique in computing known as salting
    • 0:54:19whereby we can do this instead.
    • 0:54:21If cherry we in this scheme hashes to a value like this, you know what?
    • 0:54:26Let's go ahead and sprinkle a little bit of salt into the process.
    • 0:54:29And it's sort of a metaphorical salt whereby this hash function now takes
    • 0:54:33two inputs, not just the password, but some other value known as a salt.
    • 0:54:36And the salt can be generally something super short like two characters even,
    • 0:54:40or something longer.
    • 0:54:41And the idea is that this salt, much like a recipe,
    • 0:54:43should of perturb the output a little bit,
    • 0:54:46make it taste a little bit differently, if you will.
    • 0:54:48And so concretely, if we take the word cherry and then when Carol registers,
    • 0:54:54for instance, we randomly choose a salt of 50, 5-0, so two characters,
    • 0:54:58the hash value now-- because there's two inputs--
    • 0:55:01might now be this value.
    • 0:55:02But if for Charlie, we still have cherry, but we change the 50,
    • 0:55:07we might see this instead.
    • 0:55:08Notice that for this first example, Carol, 50,
    • 0:55:11the salt is preserved in the hash value, just so you know what it was
    • 0:55:14and you can sprinkle the same amount of salt, so to speak, next time.
    • 0:55:17But that's the whole hash value for Carol in this case.
    • 0:55:21But if Charlie also has a password of cherry, but we change the salt to,
    • 0:55:26say, 49 arbitrarily, that whole hash value changed.
    • 0:55:31And so now in my hash database, I'm going to see different salts there,
    • 0:55:35different values, which is going to effectively cover up the fact
    • 0:55:39that Carol and Charlie have the same password.
    • 0:55:41Now, if we have so many users that we run out of salts,
    • 0:55:45that still might leak some information.
    • 0:55:46But that's kind of a we can kick down the road and probabilistically not
    • 0:55:50going to happen if you require passwords of sufficiently long length, most
    • 0:55:53likely.
    • 0:55:54So any questions on salting, which to be clear,
    • 0:55:58is just a mechanism for decreasing the probability
    • 0:56:01that an adversary is going to glean information
    • 0:56:03that you might not want them to have?
    • 0:56:08So what does this mean concretely?
    • 0:56:09When you get an email from a website saying "click this link
    • 0:56:13to reset your password," it's not the website, if well designed,
    • 0:56:16is being difficult or shy and not telling you your password,
    • 0:56:20the web administrators just do not know, ideally, your password.
    • 0:56:23So what are they doing?
    • 0:56:24They're probably sending you a link, similar in spirit
    • 0:56:27to a one-time password, there's some random unique string in there
    • 0:56:31that's unique to you.
    • 0:56:32They've stored that in their database.
    • 0:56:33So as soon as you click on that link, they check their database
    • 0:56:36and be like, oh, wait a minute, I know I set this link a minute ago to David.
    • 0:56:39Let me just trust now-- because probabilistically there's no way
    • 0:56:43someone guessed this URL within 60 seconds--
    • 0:56:45let's trust that whatever he wants to type in as his new password
    • 0:56:48should be associated with that Malan account in the database.
    • 0:56:51But if, conversely, you ever get an email saying your password is 123456
    • 0:56:56or whatever it is, it is clearly not being hashed, let alone salted,
    • 0:57:00on the server.
    • 0:57:01And that is not a website to do anything particularly sensitive with.
    • 0:57:06All right, so what more can we do?
    • 0:57:08Well, let's pick up where we left off in week two on the art of cryptography,
    • 0:57:12this art, the science of scrambling information, but in a reversible way.
    • 0:57:17So whereas hashing, as we've described it here, is really tends to be one-way,
    • 0:57:22whereby you should not be able to reverse the process unless you cheat
    • 0:57:25and make a massive table of all of the inputs
    • 0:57:27and all of the outputs, which isn't really so much
    • 0:57:29reversing as it is just looking it up.
    • 0:57:31Cryptography, like in week 2, can actually
    • 0:57:35be a solution to a lot of problems, not just sending messages
    • 0:57:38across a crowded room.
    • 0:57:39We, weeks ago, really focused on this type of cryptography
    • 0:57:43whereby you've got some plain text message.
    • 0:57:45You've got a key, like a secret number 1 or 13 or something else.
    • 0:57:50The cipher, which might be a rotational cipher or a substitution cipher,
    • 0:57:54some algorithm, and then ciphertext was the term
    • 0:57:56of art for describing the scrambled version.
    • 0:57:58That should look like random zeros and ones or letters
    • 0:58:01of the alphabet or the like.
    • 0:58:02This though was reversible, whereby you could just
    • 0:58:06input the ciphertext with the key and get back out the plain text.
    • 0:58:10Maybe you have to change a positive number to a negative number.
    • 0:58:13But the key is really the same.
    • 0:58:14Be it plus 1 minus 1 or plus 13 minus 13, the process was symmetric.
    • 0:58:19And, indeed, what we talked about in week two
    • 0:58:21was an example of something called secret key cryptography, where
    • 0:58:24there's, indeed, one secret between two parties, a.k.a.
    • 0:58:27symmetric cryptography.
    • 0:58:29Because encryption is pretty much the same as decryption, but maybe
    • 0:58:32you change the sign on the key itself.
    • 0:58:36But this is not necessarily all we want.
    • 0:58:39Because here's that general process.
    • 0:58:40Here's the letter A. Here's the key of 1.
    • 0:58:42We outputed in week 2 a value of B. That's not necessarily
    • 0:58:46the solution to all of our problems.
    • 0:58:47Why?
    • 0:58:48Well, if two people want to communicate securely, they need some shared secret.
    • 0:58:52So, for instance, if I wanted to send a secret message to Rongxin
    • 0:58:55in the back of the room here, he and I have better
    • 0:58:57agreed upon a secret in advance.
    • 0:59:00Otherwise, how can I possibly send a message, encrypt it in a way
    • 0:59:03that he can reverse?
    • 0:59:04I mean, I could be like, (WHISPERING) let's use a key of 1.
    • 0:59:06(SPEAKING NORMALLY) But obviously, anyone in the middle
    • 0:59:08has just now heard that.
    • 0:59:09So we might as well not communicate securely at all.
    • 0:59:11So there's this kind of chicken-and-the-egg problem,
    • 0:59:13not just contrived here in lecture.
    • 0:59:15But the first time I want to buy something on amazon.com
    • 0:59:17with my credit card, I would like my credit card to be encrypted,
    • 0:59:20scrambled somehow.
    • 0:59:21But I don't know anyone personally at amazon.com, let alone someone
    • 0:59:24that I've prearranged some secret for my Mac and their servers.
    • 0:59:28So it seems that we fundamentally can't use symmetric cryptography
    • 0:59:33all of the time, unless we have some other mechanism for securely generating
    • 0:59:37that key, which we don't have as the common case in the world today.
    • 0:59:41Thankfully, mathematicians years ago came up
    • 0:59:43with something known as asymmetric cryptography, which
    • 0:59:46does not require that you use the same secret in both directions.
    • 0:59:50This is otherwise known as public key cryptography.
    • 0:59:53And it works essentially as follows.
    • 0:59:56When you want to take some plaintext message and encrypt it,
    • 0:59:59you use the recipient's public key.
    • 1:00:02So if Rongxin is my colleague in back and he has a public key,
    • 1:00:06it is public by definition.
    • 1:00:07He can literally shout for the whole room
    • 1:00:09to hear what his public key is, which effectively is just
    • 1:00:12some big, seemingly random number.
    • 1:00:14But there's some mathematical significance of it.
    • 1:00:16And I can write that down.
    • 1:00:17Heck, you can all write it down if you too want to send him secure messages.
    • 1:00:21And out of those two inputs, we get one output, the ciphertext,
    • 1:00:24that I can then hand off to people in the room in those virtual envelopes.
    • 1:00:27And it doesn't matter if all of you have heard his public key.
    • 1:00:29Because you can perhaps guess where this is going.
    • 1:00:31How would Rongxin reverse this process?
    • 1:00:34He's not going to use one public key.
    • 1:00:36He's going to use, not surprisingly, a corresponding private key.
    • 1:00:40And so in asymmetric cryptography or public key cryptography,
    • 1:00:44you really have a key pair, a public key and a private key.
    • 1:00:48And for our mathematical purposes today, let
    • 1:00:50me just stipulate that there's some fancy math involved, such
    • 1:00:53that when you choose that key or, really, those keys,
    • 1:00:56there's a mathematical relationship between them.
    • 1:00:59And knowing one does not really give you any information about the other.
    • 1:01:02Why?
    • 1:01:03Because these numbers are so darn big it would take adversaries more
    • 1:01:06time than we all have on Earth to figure out via brute force
    • 1:01:10what the corresponding private key is.
    • 1:01:12The math is that good.
    • 1:01:13And even as computers get faster, we just
    • 1:01:15keep using bigger and bigger keys, more and more bits
    • 1:01:18to make the math even harder for adversaries.
    • 1:01:20So when Rongxin receives that message, he uses his private key,
    • 1:01:24takes the ciphertext I sent him through the room,
    • 1:01:27and gets back out the plaintext.
    • 1:01:29So this is exactly how HTTPS works effectively
    • 1:01:33to securely establish a channel between me and Amazon.com, gmail.com.
    • 1:01:38Any website starting with https:// uses public key cryptography to come up
    • 1:01:44with, initially, a secret.
    • 1:01:45And in practice, it turns out, mathematically,
    • 1:01:47it's faster to use secret key crypto.
    • 1:01:49So very often, people will use asymmetric crypto
    • 1:01:53to generate a big shared key and then use the faster algorithms thereafter.
    • 1:01:57But it does solve asymmetric cryptography,
    • 1:01:59that chicken-and-the-egg problem, by giving us all public keys and private
    • 1:02:03keys.
    • 1:02:04If you've heard of RSA, Diffie-Hellman, elliptic curve cryptography,
    • 1:02:07there's different algorithms for this that you can actually
    • 1:02:09study in higher level, more theoretical classes.
    • 1:02:12But there's a bunch of different ways mathematically to solve this problem.
    • 1:02:15But those are the primitives involved.
    • 1:02:17And how many of you have heard of now passkeys, which
    • 1:02:20is kind of only just catching on in recent months, literally.
    • 1:02:23If I had to make any prediction this semester,
    • 1:02:26odds are, you're going to see these in more and more places.
    • 1:02:29And in fact, the next time you register for a website or log into a website,
    • 1:02:32look for a link, a button that maybe doesn't say passkeys, per se.
    • 1:02:37It's often called passwordless login.
    • 1:02:40But it's really referring to the same thing.
    • 1:02:42Passkeys are essentially a newish feature of operating systems,
    • 1:02:46be it Mac OS or Windows or Linux or the OS running on your phone,
    • 1:02:50that doesn't require that you choose a username and password anymore.
    • 1:02:54Rather, when you visit a website for the very first time,
    • 1:02:56your device will generate a public and private key pair.
    • 1:03:01Your device will then send to the website for what
    • 1:03:04you're registering your public key so that it has one of the values,
    • 1:03:09but you keep your private key, indeed, private.
    • 1:03:12And using the same mathematical process that I alluded to earlier,
    • 1:03:15you can therefore log into that website in the future
    • 1:03:18by proving mathematically that you are, in fact, the owner
    • 1:03:21of the corresponding private key.
    • 1:03:24So, in essence, if we use a picture like this,
    • 1:03:26when you proceed to log in to that website again-- and, again,
    • 1:03:30that website has stored your public key--
    • 1:03:32it essentially uses something known as digital signatures--
    • 1:03:34you're familiar with this term, you've heard it in the wild--
    • 1:03:37whereby the website will send you a challenge message,
    • 1:03:40like some random number or string of text.
    • 1:03:43It's just some random value.
    • 1:03:45If you then effectively encrypt it with your private key or run both of those
    • 1:03:49through a particular algorithm, you'll get back a signature.
    • 1:03:52And that signature can be verified by the website by using your public key.
    • 1:03:57So digital signatures are kind of an application of cryptography
    • 1:04:01but in the reverse direction.
    • 1:04:03In the world of encryption, you use someone's public key
    • 1:04:06to send a message encrypted.
    • 1:04:07And they use their private key to decrypt it.
    • 1:04:09In the world of signatures, or really passkeys,
    • 1:04:12you reverse the process, whereby you use your private key to effectively encrypt
    • 1:04:16some random challenge you've been sent.
    • 1:04:18And the website, the third party, can use your public key
    • 1:04:20to verify, OK, mathematically, that response came from David.
    • 1:04:24Because I have his public key on file.
    • 1:04:26So what's the upside of this?
    • 1:04:28We just get out of the business of passwords and password managers
    • 1:04:31more generally.
    • 1:04:31You do have to trust and protect your devices, be it
    • 1:04:34your phone or your laptop or desktop all the more.
    • 1:04:36And that's going to open another possible threat.
    • 1:04:39But this is a way to chip away at what is becoming the reality
    • 1:04:42that you and I probably have dozens, hundreds of usernames and passwords
    • 1:04:46that's probably not sustainable long-term.
    • 1:04:48And, indeed, we read to often about hacks in the wild as a result.
    • 1:04:53Questions then on cryptography or passkeys?
    • 1:05:00All right, just a few more building blocks to equip you for the real world
    • 1:05:03before we sort of maybe do a final check for understanding of sorts.
    • 1:05:07So when it comes to encryption, we can solve other problems as well.
    • 1:05:11And in this too is a feature you should increasingly be seeking out.
    • 1:05:15So end-to-end encryption refers to a stronger use of encryption
    • 1:05:19than most websites are actually in the habit of using.
    • 1:05:21Case in point, if you're using HTTPS to send an email to Gmail,
    • 1:05:25that's good because no one between you and Gmail servers
    • 1:05:28presumably can see the message because it's encrypted.
    • 1:05:30It just looks like random zeros and ones.
    • 1:05:32So it's effectively secure from people on the internet.
    • 1:05:36The emails are not secure from like nosy employees at Google
    • 1:05:41who do have access to those servers.
    • 1:05:43Now, maybe through corporate policy, they shouldn't or physically don't.
    • 1:05:46But, theoretically, there's someone at Google
    • 1:05:48who could look at all of your email if they were so inclined.
    • 1:05:51Hopefully it's just not a long list of people.
    • 1:05:53But end-to-end encryption ensures that if you're
    • 1:05:56sending a message from A to B, even if it's going through C in the middle--
    • 1:06:00be it Google or Microsoft or someone else-- end-to-end encryption
    • 1:06:03means that you're encrypting it between A and B. And so even C in the middle
    • 1:06:08has no idea what's going on.
    • 1:06:10This is not true of services like Gmail or Outlook.
    • 1:06:12This is true of services like iMessage or WhatsApp
    • 1:06:16or Signal or Telegram or other services where if you poke around, also
    • 1:06:20you'll see literally mention of end-to-end encryption.
    • 1:06:22It's a feature that's becoming a little more commonplace,
    • 1:06:25but something you should seek out when you don't necessarily trust or want
    • 1:06:28to trust the machine in the middle, the point
    • 1:06:31C between A and B. So, indeed, when sending messages on phones
    • 1:06:36and even video conferencing nowadays too.
    • 1:06:38And here's something where sometimes you kind of have to dig.
    • 1:06:40Most of us are familiar with Zoom certainly by now.
    • 1:06:43And if we go into Zoom settings, which I did
    • 1:06:44this morning to take this screenshot, this is what it looks like as of now.
    • 1:06:48Here's the menu of options for creating a new meeting.
    • 1:06:51And toward the bottom here-- it's a little small--
    • 1:06:53you'll notice that you have two options for encryption.
    • 1:06:56And funny, enough the one that's typically selected
    • 1:06:58by default, unless you opt in to the other one, is enhanced encryption.
    • 1:07:02Brilliant marketing, right?
    • 1:07:03Who doesn't want enhanced encryption.
    • 1:07:05It is weaker than this encryption though, which is end-to-end encryption.
    • 1:07:10End-to-end encryption means that when you're
    • 1:07:11having a video conference with one or more people,
    • 1:07:14not even Zoom can see or hear what you're talking about.
    • 1:07:18Enhanced encryption means no one between you
    • 1:07:21and Zoom can hear or see what you're talking about.
    • 1:07:24So end-to-end ensures that it's A to B, and if Zoom is C In the story,
    • 1:07:28even Zoom can't see what you're doing.
    • 1:07:31Now, there are some downsides.
    • 1:07:32And there's some little fine print here.
    • 1:07:34When you enable end-to-end encryption on a cloud-based service like Zoom,
    • 1:07:39you can't use cloud recordings anymore.
    • 1:07:41Why?
    • 1:07:41Well, if Zoom by definition mathematically
    • 1:07:43can't see or hear your meeting, how are they going to record it for you?
    • 1:07:46It's just random zeros and ones.
    • 1:07:48You can still record it locally on your Mac or PC,
    • 1:07:50but end-to-end encryption ensures that you
    • 1:07:53don't have to worry about prying eyes-- be it a company, be it a government,
    • 1:07:56a state more generally.
    • 1:07:57And so societally, you'll start to see this discussed probably even
    • 1:08:00more than it already is when it comes to personal liberties and freedom
    • 1:08:04among citizens of countries and states because
    • 1:08:07of the implications for actual privacy that these primitives
    • 1:08:10that we've been discussing and that you even explored in week 2,
    • 1:08:13albeit weakly, with these ciphers we used in the real world.
    • 1:08:17But encryption has one other use that's worth knowing about too and yet
    • 1:08:20another feature to turn on.
    • 1:08:22So when it comes to deleting files, odds are, most everyone in the room
    • 1:08:26knows on a Mac or PC that when you drag a file to the trashcan or the recycle
    • 1:08:31bin, it doesn't actually go away unless you right click
    • 1:08:35or Control click or go to the appropriate menu and empty the trash.
    • 1:08:38But did anyone know that even when you empty the trash or recycle bin,
    • 1:08:42the file also doesn't really go away.
    • 1:08:44Your operating system typically just forgets where it is.
    • 1:08:47But the zeros and ones that compose the file or files you tried to delete
    • 1:08:51are still there for the pickings, especially
    • 1:08:53if someone gets physical or virtual access to your system.
    • 1:08:56So, for instance, here is a whole bunch of ones and zeros.
    • 1:08:59Maybe it's representing something on my hard drive.
    • 1:09:01And suppose that I want to go ahead and delete
    • 1:09:04a file that comprises these zeros and ones, these bits here.
    • 1:09:08Well, when your operating system deletes the file,
    • 1:09:10even if you click on Empty Trash or Empty Recycle Bin,
    • 1:09:13it essentially just forgets about those bits, but doesn't actually change them.
    • 1:09:18Only once you create a new file or download something else
    • 1:09:21do some of those zeros and ones end up getting overwritten.
    • 1:09:25And per the yellow remnants here, the implication of this contrived example
    • 1:09:29is that even at this point in time you can still recover
    • 1:09:32like half of the file, it would seem.
    • 1:09:34So maybe the juicy part with a credit card number
    • 1:09:36or a message that you really wanted to delete or the like, there's
    • 1:09:38still remnants on the computer's hard drive here.
    • 1:09:41So what's the alternative?
    • 1:09:42Well, if you really want to be thorough, you
    • 1:09:44could delete files and then download the biggest possible movies you
    • 1:09:47can to really fill up your hard drive.
    • 1:09:49Because, probabilistically, you would end up
    • 1:09:51overwriting all of those zeros and ones eventually.
    • 1:09:54But that's not really a tenable solution.
    • 1:09:56It would just take too much time and it's
    • 1:09:58fraught with possible simple mistakes.
    • 1:10:00So what should we do instead, well, maybe we
    • 1:10:02should securely delete information.
    • 1:10:04And securely delete would mean when you actually
    • 1:10:06empty the recycle bin or the trash can, what happens to the original zeros
    • 1:10:11and ones is that you take them and you change all of them
    • 1:10:14to zeros or all of them to ones or all of them to random zeros and ones.
    • 1:10:17Why?
    • 1:10:18So that you can still reuse those bits now,
    • 1:10:20but there's no remnants even on the computer's hard drive
    • 1:10:23that they were once there.
    • 1:10:25But even now, this is not fully robust.
    • 1:10:28Why?
    • 1:10:29It turns out that because of today's electronics and solid state devices,
    • 1:10:33there might still be remnants of files on them because these hard drives,
    • 1:10:38these storage devices nowadays are smart enough
    • 1:10:40that if they realize that parts of them are failing,
    • 1:10:42they might prevent you from changing data in certain corners.
    • 1:10:45So if you think of your memory as like a big rectangle, some of the bits
    • 1:10:48might get blocked off to you just over time.
    • 1:10:51So there might still be remnants there.
    • 1:10:53So if you really are worried about a sibling, an employer, or a government
    • 1:10:57like finding data on that system, there might actually still be remnants.
    • 1:11:01Now, you can go extreme and just physically
    • 1:11:03destroy the device, which should be pretty effective.
    • 1:11:05But that's going to get pretty expensive over time when you want to delete data.
    • 1:11:08Or, again, we can use encryption as the solution to this problem.
    • 1:11:13So, again, encryption is increasingly in the real world
    • 1:11:15an amazing tool for your toolkit because it can be deployed in different ways.
    • 1:11:19So, in this case, full disk encryption is something
    • 1:11:22you can enable in Windows or Mac OS.
    • 1:11:24Nowadays, it's typically enabled by default on iOS
    • 1:11:27and you can opt in as well on other platforms.
    • 1:11:29In the world of full disk encryption, instead of storing any of your files
    • 1:11:33as a plain text, like in their original raw format,
    • 1:11:37you essentially randomize everything on the disk instead.
    • 1:11:41You rely on the user's password or some unique string
    • 1:11:45that they know when you log into your Mac or PC
    • 1:11:47to essentially scramble the entire contents of the hard drive.
    • 1:11:49And it's not quite as simple as that.
    • 1:11:51Typically, there's a much larger key that's
    • 1:11:53used that in turn is protected by your actual password.
    • 1:11:56But, in this case, this means that if someone steals your laptop while you're
    • 1:12:01not paying attention in Starbucks or the airport or even your dorm room,
    • 1:12:04even if they open the lid and don't have your password,
    • 1:12:07they're not going to be able to access any of the data
    • 1:12:09because it's just going to look like zeros and ones.
    • 1:12:11Even if they remove the hard drive from your device,
    • 1:12:13plug it into another device, they're only going to see zeros and ones.
    • 1:12:16Now, if you walk away from your laptop at Starbucks with the lid open
    • 1:12:21and you're logged in, there is a window of opportunity.
    • 1:12:24Because the data has got to be decrypted when you care about it and when
    • 1:12:27you're using it.
    • 1:12:28So here too is another example of best practice.
    • 1:12:31You should minimally be closing the lid of your laptop,
    • 1:12:33making sure it's logging you out or at least locking the screen,
    • 1:12:36so that someone can't just walk off with your device
    • 1:12:39and have access to your logged in account.
    • 1:12:42But full disk encryption essentially decreases the probability
    • 1:12:45that an adversary is going to be successful.
    • 1:12:47In the world of Macs, it's called FileVault.
    • 1:12:49It's in your System Preferences.
    • 1:12:50Windows, it's called BitLocker.
    • 1:12:51There's third party solutions too.
    • 1:12:52Here too, we have to trust that Microsoft and Apple don't
    • 1:12:55screw up and write buggy code.
    • 1:12:57But generally speaking, turning on features like these things
    • 1:13:00are good for you.
    • 1:13:02Except what's maybe an obvious downside of doing this?
    • 1:13:08What's that?
    • 1:13:08AUDIENCE: [INAUDIBLE]
    • 1:13:09DAVID MALAN: Yeah, if you forget your password.
    • 1:13:11There's no mathematician in the world who
    • 1:13:12is probably going to be able to recover your data for you.
    • 1:13:15So there too, it's maybe a hefty tradeoff.
    • 1:13:17But hopefully you have enough defenses in place,
    • 1:13:19be it your-- a good password, a password manager,
    • 1:13:22maybe even printing out your primary password on a sheet of paper,
    • 1:13:25but locking it in a box or bringing it home so that no one near you
    • 1:13:28actually has physical access, you can at least mitigate some of these risks.
    • 1:13:32You'll read about, though, in the real world even this,
    • 1:13:34which is like an adversarial use of full disk encryption.
    • 1:13:37Sometimes when hackers get into systems, this
    • 1:13:39has happened literally with hospital systems, municipal government systems,
    • 1:13:42and the like.
    • 1:13:43If they hack into them, they don't just delete the data or just create havoc,
    • 1:13:47they will proactively encrypt the server's hard drive
    • 1:13:51with some random key that only the hacker knows.
    • 1:13:53They will then demand that the hospital or the town
    • 1:13:55pay them, often in Bitcoin or some cryptocurrency
    • 1:13:58to decrease the probability of being caught,
    • 1:14:00and they'll only turn over that key to decrypt the data if someone actually
    • 1:14:05pays up.
    • 1:14:06So here too, there's sort of a dark side of these mathematical principles.
    • 1:14:09So there too, it's always a trade off between good people and perhaps bad.
    • 1:14:15Well, maybe before we wrap and before we serve
    • 1:14:17some cake in the transept, Carter, can you join me one last time?
    • 1:14:20But, first, before I turn things over to me and Carter, here's your problem
    • 1:14:23set 10, a sort of unofficial homework.
    • 1:14:26One, among your takeaways for today, you should
    • 1:14:28start using a password manager or even these fancier passkeys, at least
    • 1:14:32for your most sensitive accounts.
    • 1:14:34So anything medical, financial, particularly personal,
    • 1:14:37like this is a very concrete takeaway and action item.
    • 1:14:40I wouldn't sit down and try to change all of your accounts over.
    • 1:14:42Because knowing humans, You're not going to get through the whole to-do list.
    • 1:14:45So maybe do it the next time you log into that account,
    • 1:14:48turn on some of these features or add it to a password manager
    • 1:14:50or at least start with the most important.
    • 1:14:52Two, turning on two-factor authentication
    • 1:14:54beyond where you have to at places like Harvard and Yale,
    • 1:14:57but certainly bank accounts, privates, anything medical, personal,
    • 1:15:00or the like.
    • 1:15:01And then lastly, where you can, turning on end-to-end encryption.
    • 1:15:04Being careful with it, you don't want to go
    • 1:15:07and during lecture, hopefully no one clicked the turn on FileVault button
    • 1:15:10while we're in class.
    • 1:15:11Because closing your laptop lid while things are being encrypted
    • 1:15:14is generally bad practice.
    • 1:15:16See us after though if you did do that a moment ago.
    • 1:15:18So here's just then three actionable takeaways.
    • 1:15:21But we thought we'd conclude by taking a few final minutes for a CS50 quiz
    • 1:15:24show of sorts, a final check for understanding using some questions
    • 1:15:28we come up with ourselves, but also some of the review questions
    • 1:15:31that you all kindly contributed as part of the most recent problem set.
    • 1:15:34So some of these questions come from you yourselves.
    • 1:15:37And let me go ahead and turn things over to Carter here to help run the show.
    • 1:15:41We will invite you at this point to take out that same device
    • 1:15:46as you had earlier.
    • 1:15:47This is the same URL as before.
    • 1:15:48But if you closed the tab, you can reopen it here.
    • 1:15:52To make things a little fun-- because we still have some cookies
    • 1:15:54left-- could we get three final CS50 volunteers?
    • 1:15:58OK, one hand is already up.
    • 1:15:59How about two hands there?
    • 1:16:01And how about three hands?
    • 1:16:03Over here.
    • 1:16:03All right, yes, sure, a round of applause for our final volunteers.
    • 1:16:06Come on up.
    • 1:16:07[APPLAUSE]
    • 1:16:10On the line are some delicious Oreo cookies.
    • 1:16:13If the three of you would like to come over and take
    • 1:16:15any of these seats in the middle, you will be our human players,
    • 1:16:18but we'll invite everyone in the group to play too.
    • 1:16:20Do you want to take a mic and introduce yourself to the world?
    • 1:16:22AUDIENCE: Sure.
    • 1:16:23Hi, I'm Dani.
    • 1:16:25I'm a first year in WIG C. And I'm planning on studying economics.
    • 1:16:29DAVID MALAN: Nice, welcome.
    • 1:16:31AUDIENCE: Hi, I'm Rochelle.
    • 1:16:32I'm from the best state, Ohio.
    • 1:16:34DAVID MALAN: [INAUDIBLE]
    • 1:16:35AUDIENCE: And I'm a freshman in Greeno.
    • 1:16:37I'm planning on concentrating in CS.
    • 1:16:39DAVID MALAN: Nice, welcome.
    • 1:16:40And?
    • 1:16:41AUDIENCE: My name is Jackson.
    • 1:16:43I'm from Indiana.
    • 1:16:43I live in Thayer.
    • 1:16:44I'm a first year.
    • 1:16:45And I'm studying linguistics and Germanic languages and literatures.
    • 1:16:49DAVID MALAN: Welcome as well.
    • 1:16:50So, if our volunteers could have a seat, you're
    • 1:16:52going to want to be able to see this screen or that one.
    • 1:16:54So you can move your chairs if you would like.
    • 1:16:56Carter is going to kindly cue up the software, which hopefully everyone
    • 1:16:59has on their phones as well.
    • 1:17:00And I should have mentioned, do you have your phone with you?
    • 1:17:02AUDIENCE: [INAUDIBLE]
    • 1:17:03DAVID MALAN: Do you have your phone with you?
    • 1:17:04AUDIENCE: [INAUDIBLE]
    • 1:17:04DAVID MALAN: OK, do you have your phone over there?
    • 1:17:06OK, what's your name again?
    • 1:17:07AUDIENCE: Rochelle.
    • 1:17:08DAVID MALAN: OK, Rochelle will be right back,
    • 1:17:09if you want to go grab your phones.
    • 1:17:10And in the meantime, we're going to go ahead and-- thank
    • 1:17:13you so much-- we're going to go ahead and cue up the screens here
    • 1:17:16for the CS50 quiz show.
    • 1:17:17It's about 20 questions in total, the first few of which
    • 1:17:19are going to focus on cybersecurity to see how well we
    • 1:17:23can check our current understanding.
    • 1:17:24The rest will be questions written by you in the days leading up to today.
    • 1:17:29All right, Carter, let's go ahead and reveal the first question.
    • 1:17:32And note that you can win up to 1,000 points this time per question.
    • 1:17:35It's not just about being right or wrong.
    • 1:17:37And you get more points the faster you buzz in as well.
    • 1:17:40So we'll see who's on the top based on all of the guest user names.
    • 1:17:43All right, here we go, Carter, question one,
    • 1:17:45what is the best way to create a password?
    • 1:17:48Substitute letters with numbers or punctuation signs,
    • 1:17:50ensure it's at least eight characters long,
    • 1:17:53have a password manager generated for you,
    • 1:17:55or include both lowercase and uppercase letters?
    • 1:18:00All right, let's see what the results are.
    • 1:18:03Almost everyone said have a password manager generate it for you.
    • 1:18:0790% of you said that's the case.
    • 1:18:10And, indeed, that one is correct.
    • 1:18:11Nicely done.
    • 1:18:12Let's go ahead and see the random usernames you've chosen.
    • 1:18:15So this looks like it's web_hexidecimalidentifier to keep
    • 1:18:19things anonymous.
    • 1:18:20So if you are OAF9E, nicely done, but there's
    • 1:18:23a whole lot of ties up at the top.
    • 1:18:25All right, and I see-- well, just to keep things interesting,
    • 1:18:27you had 792 points.
    • 1:18:28You had--
    • 1:18:29AUDIENCE: 917.
    • 1:18:30DAVID MALAN: 917 points, 917 points.
    • 1:18:33So it's a close race here.
    • 1:18:34Number two, what is a downside of two-factor authentication?
    • 1:18:38You might lose access to the second factor.
    • 1:18:40Your account becomes too secure.
    • 1:18:42You can be notified someone else is trying to access your account.
    • 1:18:45You can pick any authentication you like.
    • 1:18:48Hopefully, you can reload.
    • 1:18:49You might have missed that one.
    • 1:18:50And the number one answer was might lose access to the second factor.
    • 1:18:53Indeed, 93% of you got that.
    • 1:18:55And we're up to 1,375 points, 792 points, and--
    • 1:18:59AUDIENCE: [INAUDIBLE]
    • 1:19:00DAVID MALAN: OK, and forced reload.
    • 1:19:01So, yes, you tried reloading the page and hopefully it'll click back in.
    • 1:19:04All right, Carter, number 3.
    • 1:19:05We have, what would you see if you tried to read an encrypted disk?
    • 1:19:09You would see a random sequence of zeros and ones,
    • 1:19:12scrambled words from the user's documents,
    • 1:19:14all of the user's information, or all one's?
    • 1:19:18About 10 seconds remain.
    • 1:19:20Is it working for you now?
    • 1:19:21OK.
    • 1:19:22All right, three seconds.
    • 1:19:24And the ranked answers are a random sequence of zeros and ones.
    • 1:19:2991% of you indeed got that right.
    • 1:19:31Let's see who's winning on the guest screen.
    • 1:19:34Web user a28c3, nicely done.
    • 1:19:37But it's still a close tie among three of you anonymous participants.
    • 1:19:41Number four, which type of encryption is most secure--
    • 1:19:45enhanced encryption, end-to-end encryption, full scale encryption,
    • 1:19:49advanced encryption?
    • 1:19:54About five seconds.
    • 1:19:59And most popular response is the correct one, end-to-end encryption
    • 1:20:04with 92% of you.
    • 1:20:06Nice.
    • 1:20:06We're up to 2,375, 3,792, and 2,917.
    • 1:20:13And good job to these three folks in the front of our list.
    • 1:20:18All right, Carter, number 5, the last on cybersecurity.
    • 1:20:21When would it make sense to store your password on a sticky note
    • 1:20:23by your computer?
    • 1:20:25When it's too complicated to remember, when
    • 1:20:27you need to access your account quickly, when you share your account with family
    • 1:20:31members, never.
    • 1:20:37Oh.
    • 1:20:39And the most popular response was never, which is indeed correct.
    • 1:20:43And only 79% of you think that right now.
    • 1:20:46It is never OK to store it on a post-it note on your computer.
    • 1:20:50You should minimally be using today's password manager for that same process.
    • 1:20:54All right, two of you, a28c3 and c9a23 are still atop the list.
    • 1:21:00We have 3,000-plus points, 3,000-plus points,
    • 1:21:03and probably about the same as well.
    • 1:21:06All right, now we move on to the user-generated content
    • 1:21:09that you all from Harvard and Yale generated for us.
    • 1:21:11Number 6, what is the variable type that stores true/false values?
    • 1:21:16Boolean, string, integer, or double?
    • 1:21:22About 10 seconds to come up with this.
    • 1:21:25We saw these in different languages, these types.
    • 1:21:27But the idea was the same.
    • 1:21:29And in two seconds, we'll see that the answer
    • 1:21:32is Boolean with 96% response rate.
    • 1:21:36All right, what else do we have here?
    • 1:21:39It's still a two-way tie at the top.
    • 1:21:41All right, next question, Carter, is number 7.
    • 1:21:44What placeholder would you use when trying
    • 1:21:46to print a float in C, a float in C?
    • 1:21:55Seven seconds.
    • 1:21:58I'll defer to the visual syntax on the screen for this one.
    • 1:22:01And the most popular and correct answer is, indeed, %f.
    • 1:22:06We never saw %fl and we definitely didn't see %float.
    • 1:22:10Two of you, though, are still in the lead.
    • 1:22:12Nicely done, whoever you are.
    • 1:22:14All right, next question, what does I++ do in C++ where I is an integer value?
    • 1:22:23Note, for the record, we did not teach C++ in this course,
    • 1:22:26but this question is from you.
    • 1:22:29I will admit it's the same as in C, which we did teach.
    • 1:22:34Decrements the integer, deletes the integer, increments the integer by one,
    • 1:22:37or reassigns the integer to zero?
    • 1:22:40The most popular answer and correct answer
    • 1:22:42is increments the integer by one.
    • 1:22:45It definitely doesn't decrement, so.
    • 1:22:47All right, two responses still atop the list.
    • 1:22:49And here we have 6,000-plus, 6,000, and 6,000.
    • 1:22:52So it's getting closer.
    • 1:22:53Using a hash table to retrieve data is useful
    • 1:22:56because it theoretically achieves a search time of O of n, O of n log n,
    • 1:23:03O of log n, or O of 1?
    • 1:23:09Five seconds to make your decision.
    • 1:23:10Getting a little harder.
    • 1:23:13And let's see the results.
    • 1:23:16O of 1, only 30% of you got the correct answer from a very core week 5 topic.
    • 1:23:24That is the theoretical hope of a hash table.
    • 1:23:27In practice, though, to be fair, it can devolve, as we saw, into O of n.
    • 1:23:33We didn't really see those other two answers in the context of hash tables
    • 1:23:36specifically.
    • 1:23:37All right, wow, a28c3 is in the lead now.
    • 1:23:41Let's take a look at number 10, halfway there.
    • 1:23:46What is the first program we made in CS50?
    • 1:23:48This should be fast.
    • 1:23:49All right, Greet, Meow, DNA, Hello, world?
    • 1:24:03One second.
    • 1:24:04And it was, indeed, Hello, world, Hello, world.
    • 1:24:10All right, still in the lead with 10,000 points.
    • 1:24:15And now let's move on to the second half.
    • 1:24:17Question 11, when malloc is used to allocate memory in a C program,
    • 1:24:21that memory is allocated in the pile, heap, bin, or stack?
    • 1:24:30Very creative set of answers.
    • 1:24:35Five seconds.
    • 1:24:40All right, and the results have heap at 43%.
    • 1:24:46Malloc was from the heap at the top.
    • 1:24:49The stack is where function calls go.
    • 1:24:52It's getting a little more worrisome here.
    • 1:24:54But that's OK.
    • 1:24:56Still in the lead with perfect score, it seems, 11,000 points.
    • 1:24:59Next up is number 12.
    • 1:25:02Which data structure allows you to change its size dynamically and store
    • 1:25:06values in different areas of the memory--
    • 1:25:08an array, a queue, a linked list, or a stack?
    • 1:25:15Change its size dynamically and store different values
    • 1:25:18in different areas of the memory.
    • 1:25:21And the answer from the group is a linked list at 62%, which is correct.
    • 1:25:28An array, as we defined it, cannot be resized.
    • 1:25:31You can create a new array, copy everything over.
    • 1:25:34I'm starting to think maybe we shouldn't end the class on this note.
    • 1:25:37But that's OK.
    • 1:25:38We'll move on.
    • 1:25:3912,000 points for the lead.
    • 1:25:41And number 13, what does CSS stand for in web development--
    • 1:25:46computer style sheets, cascading style sheets, creative style systems,
    • 1:25:50colorful sheets styles?
    • 1:25:53And most popular answer is correct with 81%, cascading style sheets.
    • 1:25:59On the top 10 list here at 1,300 points, still a perfect score,
    • 1:26:03and our three human volunteers are doing well here too.
    • 1:26:0714, how to represent a decimal number 5 in binary.
    • 1:26:11All right, here we go.
    • 1:26:13I'll let you read these.
    • 1:26:23All rights, fingers crossed, decimal number 5 in binary is, indeed, 101.
    • 1:26:31Because that's a 4 plus 0 plus 1 gives us a decimal 5.
    • 1:26:36All right, next question, and amazing a28c3, whoever you are out there,
    • 1:26:41nicely done.
    • 1:26:42Who is the CS50 mascot--
    • 1:26:44cat, duck, robot dog Spot, Oscar the Grouch?
    • 1:26:49All of whom have appeared in some form.
    • 1:26:55This one will be a little looser with answers, but looks like duck and cat
    • 1:27:03were both the most popular.
    • 1:27:04Duck has kind of become the mascot, suffice it to say.
    • 1:27:07Cat is kind of everywhere on CS50 social media.
    • 1:27:09So we'll accept cat as well.
    • 1:27:11We love Spot, but has only made that one appearance.
    • 1:27:1415,000.
    • 1:27:16Final few questions, what is the output of printf quote, unquote, "1" plus
    • 1:27:20quote, unquote, "2?"
    • 1:27:23It will return an error, twelve, 3, or 12?
    • 1:27:27English and digits respectively there.
    • 1:27:31Six seconds.
    • 1:27:36All right, one second.
    • 1:27:37And 12 with 74% is correct.
    • 1:27:42Because it's not quite 12, it is more rather
    • 1:27:451, 2 because those are two strings that got concatenated would not actually
    • 1:27:49be an error in that case.
    • 1:27:50It's just not what you expect.
    • 1:27:52All right, it's getting a little harder, but still someone's
    • 1:27:55got a perfect score.
    • 1:27:56What does LIFO stand for?
    • 1:27:58Lost In First Order, Last In First Out, Let Inside Fall Outside,
    • 1:28:04Long Indentation For Organization?
    • 1:28:08Good one.
    • 1:28:14Last In First Out, and we discussed this in the context of a stack.
    • 1:28:19Because as you pile things on top of the stack,
    • 1:28:21the last one in is the first one out.
    • 1:28:23All right, nicely done, this player here.
    • 1:28:25Three questions to go.
    • 1:28:26On average, how early did you submit the weekly pset?
    • 1:28:30A couple of days early, no rush, the morning of, a couple of hours early,
    • 1:28:34but was not too nervous, 11:59:59, I live on the edge.
    • 1:28:40Again, user-generated content.
    • 1:28:44And the most popular answer--
    • 1:28:47[LAUGHTER] Carter and I conferred before class
    • 1:28:51and we autocratically decreed that this is
    • 1:28:53the only right answer and the only one we
    • 1:28:55will accept here, though we appreciate the others as well.
    • 1:29:01Wow, all right, did you take this class for the CS50 shirt?
    • 1:29:07Yes, no, maybe, I'm not telling you?
    • 1:29:13So that is this here shirt, which you'll get at the CS50 fair.
    • 1:29:20One second.
    • 1:29:23And, yes, no, maybe, I'm not telling you, this time, we'll accept all four
    • 1:29:27of those, which brings us to our final question, at which point
    • 1:29:30we'll reveal the scores of all of our participants
    • 1:29:32and see if we can get the number one score online.
    • 1:29:34What is the phrase that David says at the end of each lecture?
    • 1:29:41[INTERPOSING VOICES]
    • 1:29:49DAVID MALAN: All right, before we actually
    • 1:29:51say what the right answer is, though we can show it,
    • 1:29:54Carter, we'll see that there is 98%--
    • 1:30:00I've never said this at the end here, but 98% answers there.
    • 1:30:04Let's go ahead and look at the top chart.
    • 1:30:05Do we know who web_a28c3 is?
    • 1:30:11Oh my goodness, come on down.
    • 1:30:12And among our friends here, can you pull up each of your scores
    • 1:30:16if you're able to see?
    • 1:30:20And among our human volunteers, 16,792, 17,292, 16,958.
    • 1:30:29So we have our human winner as well.
    • 1:30:32So without further ado, allow me to thank our volunteers.
    • 1:30:36Thanks so much to CS50 staff.
    • 1:30:37We're about to give out some cookies and, if you want,
    • 1:30:38some stress balls here.
    • 1:30:39Cake is now served.
    • 1:30:41And this was CS50.
    • 1:30:43[CHEERING]
    • 1:30:45[INTERPOSING VOICES]
    • 1:30:47[MUSIC PLAYING]
  • CS50.ai
Shortcuts
Before using a shortcut, click at least once on the video itself (to give it "focus") after closing this window.
Play/Pause spacebar or k
Rewind 10 seconds left arrow or j
Fast forward 10 seconds right arrow or l
Previous frame (while paused) ,
Next frame (while paused) .
Decrease playback rate <
Increase playback rate >
Toggle captions on/off c
Toggle mute m
Toggle full screen f or double-click video