Just a weeklater, westartedhandingyoulargefileslikethis, andofallthingsyouwereabletodeducebywritingsomepythoncodethatthisisLavendersDeanna, amongothersintheclassofwhosefileswehandedyouandthenmostrecently, orperhapsquitesoon.
Sointryingtothinktodayaboutwhatwehopeyourowntakeawaysarefromnotonlythecourse, butcomputerscienceMoregenerally, I actuallypulledupsomeofmyownnotesyoumightrecallfromWeekZerothat I mentioned I tookthiscoursemyselfbackin 1996 andwhathappenedtobetheonethatturnedmefrom a governmentmajorto a computersciencemajor, and I didn't takemanynotesatfirst.
Itseems, inthatfirstclass, therewere a coupleofotherpages, andso I startedflippingthroughtheseAndinfact, thiswasmysecondpageofnotes.
Andifyoufocuswhat's onwhat's uphereatthetop?
Apparentlyoneofmyfirstnotestomyselfat a functionforthoseunfamiliartodayourinstructionsthatdotheworkon.
Indeed, if I lookeddownfurtheronmynotesarguments, weintroducethatsamefirstday.
Andsolongasallofthehumansintheworldagreeonthat, whethersending e mailsortextmessagesorthelike, ourcomputersystemscanallpresentinformationthatweultimatelyunderstand.
AnotherreviewquestionfromWeekzero.
Whatdidthissaywaybackwhen, Ifyouneed a hint, itwasitwasinvesting 128,514.
Thatway a littleletteremoji.
Thiswasthefacewithtearsofjoy, Right, takingallofthefunoutofsendingemojisAnytimeyoureceiveorsendanemoji, really, allyou'resendingis a patternofzerosandonesorworsethenumber 128,514.
Butyourcomputerorphonearepresentingittoyouin a certainwaybasedonthatcontext, allbasedonjusthowwehumansare.
Thereareanotherpiecetothepuzzlein, so I actuallylookbackonmyownthirdpageofnoteshereandfocusedonmyfirstlineherebackin 1996.
Analgorithmisapparently a precisesequenceofstepsforgettingsomethingdone, andprogrammingmoregenerallyis, ah, processoftakinganalgorithmandputtingitinto a language a computercanprocess.
Andoneproblemis, isn't wasratheroldschool, andwethoughtwe'd reflectjust a bidandperhapsreinforcedthatsameweek, zeroitbytaking a coupleofvolunteers, perhaps a studentandoneoftheirfamilymembers, voluntarilyorforcibly, withthem.
Okay, I seeonevolunteerandeithermomordadfightingoutwho's notgoingtogoup.
Okay, Comeonup.
A roundofapplause, ifwecouldforourvolunteers.
Comeonoverthisway.
Andwhatisyourname?
Daniella.
Nicetomeetyou.
Comeonoverhere.
Andwhatisyourname?
Mariano.
Andyourdad, I presume.
Allrights.
Well, sonicetoseeyouboth.
You'llrecallfromweekzerothatoneofthefirstproblemswesolvedwaslookingupsomeonein a phonebook.
Well, here I have a prettythickyellowpageswhereinthere's a wholebunchofproductsandserviceisalphabetizedfrom A to Z, andwecan, ofcourse, lookupthenumberforsomeoneinthisbook.
Forinstance, SupposedtodayweneedAh, plumber.
CouldweaskMarianotofindus a plumberinthisphonebook?
AndsoallofusmighthaveanintuitiveunderstandingItjustlikeMarianodidforfindingplumbersbyjumpingtothe P section.
Butthenyoucameclosetothe p sectionbutthenstartedflipping.
And I daresayyouyouflipthroughfarmorepagesthanyouultimatelyneededtousingarmorefficient, divideandconquerifonetimeonlyalgorithminstead.
Sobeyondalgorithmsrecall, um, I recallthat I hadjust a fewothernotes.
Mylastpageofnotes.
I alsohadthisyearthatwhatwasapparentlyimportantthenandnolesssonowisthatincomputerscienceandinturn, programmingprecisionisimportantandcorrectnessisimportant.
Solet's see, perhapswithonemoredemonstration, justhowmuchthisonehaspercentperhapssunkin.
Ifwecouldgetperhapstwomorevolunteersofstudentsandfamilymemberaswellstudentandfamilymemberhereand I don't see a familymember's handup.
Canyouconvinceone?
Okay, comeonup.
Wonderful.
A roundofapplauseforourotherpowervolunteer, sir.
Sonowforthisone, noteveryone's offthehook.
Ifallofthestudentsintheroom, iftheyhave a pieceofpaperandorpenorpencilcouldtakethatoutandsharewithanyonenexttoyouifyoudon't haveEmmaandBrianarealsogonnapassoutsomepaperandpensifyoudon't have a writingapparatus.
Andwhat I'm gonnashowDavidinjust a momentisanimageonthescreenthat I'm goingtoaskthatheprogramyoutheaudiencetodraw, givingverbalinstructionsonlythegoalofwhichisforhimtobeaspreciseaspossibleandascorrectaspossibletocompeltheaudiencemuchlike a computertofollowhisinstructionsand, inturn, implementyouralgorithm.
Soinjust a moment, Davidisgoingtorattleoffstepbystepinstructionsforhavingeveryoneintheaudiencedrawthis.
Youaretheonlyonethatcanseewhat's onthescreen.
Everyoneintheaudiencejustabouthas a pieceofpaperand a penorpencil, and I justneedyouveryconfidentLeah, clearlytorecitestepbystepinstructionsbywhicheveryonewiththeirpenorpencilcandrawwhatyouseeonthescreenheremakesense.
And I daresayoneofthethingsthatweencourageyouasyouexit, ofcourselikethisisnotjustwhatyoucando, butfrankly, whetheryoushoulddoit.
Andindeedallthemorerelevanttodayinsocieties, ofcourse, stories, horrifyingstoriesoffwhereourdatahasendedup, orwhathashappenedtoourdataorgoodintentions, perhapsgoingtowritebecausewehaven't consideredimplicationsandwhatwewantedtodotodayistopointout a fewexamplesoffopportunitiestothinkharderaboutwhatitisyoudointherealworldisjust a citizenandwhatyoudointheonthekeyboardas a programmerandhowyoumightsolveproblemswithone's privacyandthesecurityofone's datainmind, consider, forinstance, passwords.
These, ofcourse, areperhapsthemostfamiliarthingthatyouand I useprobablyeverydaytosecureouraccountsandinturn, maintaintheprivacyofourinformation, whetherit's ourphotographsorfinancialdocumentsor e mailsortextmessagesorthelike.
Forinstance, in 2019 alreadybasedon a verylargedatabreachandintheannouncesthereof, itturnsoutthatthetop 10 passwordsintheworldasofthisyearournumberone 123456 apparentlytheresultofsomewebsiteorapplicationsrequiring a passwordofatleastsixcharacters.
Well, evenifyou'veprotectedyourfinancialaccountsorsomeotheraccountwith a sixdigitcode, youknow, itmighttake a humanquite a whiletoguessallofthepossiblecodesthatyoumighthavechosen.
Butit's notterriblyhardfor a computer.
Infact, we'lldoitevenmoresimplylike a lotofteamswith a fourdigitcode.
I cansimplygoinprogramlikethisif I know a bitofprogrammingandpython.
And I cansayfromtimeimportsleep I cansaysomethinglikefour I inrange.
Andtheninhere, I'm gonnagoaheadandsaysomethinglike, I amcheckingthisvalue, I Sothisistosay I'm proposingtowrite a programinPythonthatwilltrytocracksomeone's pintoshowhoweasyitistogenerateas a computerallofthepossiblepinsintheworldthatarefourdigitslong.
So, andjusttodemonstratethis, I'm goingtodoit a littleslowlybysleepingfor, like, uh, 1/10 of a secondbetweenitsgeneration.
So I'vegoneaheadandsavedmyfile.
I'm gonnagoaheaddownherenowandrunpythonof, um, I'm gonnagodownhereandrunpythonofpindotpieand I'llgoaheadandmakemyscreen a littletallerheresowecanseemore.
Whoops.
Ah, thankyou.
No, thankThankyou.
Newhere.
Okay, soherewego.
We'venowwritten a programthatgrantedisnotcrackinganything, butitisdemonstratinghoweasilyandhowquicklywecangeneratenumbersfromzeroonupto 9999.
Now, maybeyou'reoffthehookbecauseyou'renotassimplisticas I claimastouseonLee, forinstance, inalphabeticalorrather, a numericcode, maybeyou'reusingAh, wordandnot a wordassimpleaspassword.
Youknow, it's a morearcanewordfromEnglishorperhapssomeotherlanguage, youknow.
I'm gonnagoaheadandcreateanotherfile, thoughthisonecalledpassworddotpieandrecallfromsomeofourbuildingblocksoverthepastfewweeksHoweasyitistosimilarlymanipulatewordsfrom a dictionary.
Andoverhere, I'm gonnagoaheadandsaynow, for a wordin, I wanttosayfileandwe'venotperhapsseeingthisone.
Butitturnsoutthere's a reallyeasypythonfunctionwhereyoucansayfiledotreadlines.
Andit's justgonnaslurpinallofthe 140,000 wordsfromthefileandallowyoutoreiterateoverthemoneat a time.
Andif I wanttogoaheadandprintthisout, I'lluseprintagainasbefore, and I'm gonnagoaheadandclaimthat I'm checkingforinstance, thatworddot, dot, dotJustas I claimtobechecking a pin.
Nowagain, I'm notcheckinganything.
I'm justdemonstratingthat I couldbecheckingthisfastasbysimplyprintingoutthesewordsinstead.
And I'm gonnagoaheadandasbefore, sleepfor 1/10 of a secondoneachgeneration.
ThisisPythonofpastPythonof, Ah, runthisaspythonoffpassworddotpieandwe'llsee, asthestudentswillrecallallofthewordsinthedictionary, startingwiththe a wordsthanthe B wordsthanthe C wordsandsoforthallthewaydownthrough F.
Whichistosay, ifyou'rechoosing a password, that's just a wordinthedictionary, Whetherit's Englishorsomeotherlanguage, you'renotoffthehook.
You'renotbeingsocleverbecauseanyonewith a computercancheckallofthosecodesnowyoumightthink, Well, thisiswhysomeonehad a B C 123 That's notinthedictionary.
That's notjustnumbers.
That's notjustletters.
Butcomeon, ifyougiveme a fewmoreminutes, I betwecouldwrite a programtogetherthatstartswithlettersandendswithnumbers, orviceversa.
Wecouldtrytoconcoctthesepatterns, andgranted, it's gonnaget a littleslower, littleslower, themorecomplicateditgets.
Nowthatmightseem a littlecreepyatfirstglance, anditcanbeusedforcreepypurposes, advertisingandothersuchtrackingapplicationsamongthem.
Butthisisactually a veryusefulprimitiveandcomputerscienceinWebprogramminginthatifyouhavetheabilitytoplant a littlefileonsomeone's computer, it's kindoflikethedigitalversionof a handstamp.
Youcanrememberthatyou'veseenthembefore, andthat's actuallyuseful, becausewhenyoulogintoGmailorwhateveremailaccountyouhave, youdon't reallywanttobetypinginyourusernameandpasswordeverytimeyoulookat a newmessage, right?
GmailorGooglewouldbe a littleobnoxiousiftheykeptaskingyou.
Thisisreallythedomainofindiedevelopersorprogrammers, but I'veclickedonthisnetworktabherebecauseonmyownMacorPCIf I visitsome u.
R l likewwwdotgoogledotcomandhitEnter, I canactuallyseeinsideofChromealloftherequestsmycomputerhasjustmadeovertheInternetformetogoogledotcom, and I'm gonnagoaheadandclickontheveryfirstofthesehere, Andthis, too, isgonnalookprettyarcanefortoday's purposes.
Itlooks a littleweird, apparentlyisgonnaexpireinDecember, so I caninferfromthisthatGooglewantstobeabletoremembermeatleastfor a couplemoremonthstotheendoftheyearandthisvalueherecollectivelywouldseemtobelike a sortofhandstamp.
They'veputonmycomputersothatif I nowproceedtodosearches, if I proceedtologintoGmail, useGooglecalendarthelike, theyknowwho I amortheyknowthatit's meagainandagain.
Well, thatmeansliterallythatevenifGoogleorFacebookorsomeotherwebsitesendsyou a setcookievaluesayingpleasestorethischromeinthiscaseisjustgonnathrowitaway.
It's gonnaemptythecookiejarsotospeak.
Onceyouclosethatincognitowindow, however, yourbrowserisstillsendingtoGoogleorFacebookorwhateverwebsiteyou'revisitingthosevaluesagainandagainandagain, yoursnotprivatewithinthatwindowperse.
So, forinstance, if I gonowhereandgotoviewdeveloperanddevelopertools, and I havemynetworktabopenagainand I visitsomethinglikehttpscolonslashslashdub, dubdubdotgoogledotcomandhitEnter, you'llseethatGoogleisindeedstillplanting a cookie.
Thistime I gottwocookiesfromGoogleonmycomputer, andthosecookieswillexistforaslongas I havethisincognitowindowopensoGooglemightbeabletoinferwho I amorthat I amthesamepersonbasedonthesecookies.
Buttheyknowevenmorethanthat, if I scrollbackdowntowherewebegantotheserequestheaders, theinformationmybrowserissendingtotheserver, you'llnoticethatamongthesevaluesissomethinglikethis.
Butitlookslikeforwhateverreason, mycomputeristellingGooglewithoutmyevenaskingittothat I'm using a MacAh, that I'm runningMacOS 10.14 pointsixatthemoment.
Andif I keepscrolling, it's gonnatellitfurtherthatthisis a specificversionofGoogleChrome, andthisisjustsomeoftheinformationthatisleakeddeliberatelyandoftenforgoodpurposes.
Allofushaveuniqueaddressesthatarestillbeingpresentedtotheseservers, andsothroughcomputerscience, theircourseslikethis, andthroughreadinguponthesekindsoftopics, hereonafter I realizedthatinunderstandingtheseprintsprimitives, thesethingslikecookiesandhowthey'resetcanyouatleastthenwehope, make a moreinformeddecisionastowhethertousetheminthatwayornot, ortovisitwebsitesinsomewaythatyouknowtobe, um, usingthemforsomepurpose.
Theyclaimtobedeletingyourphotosaftersomenumberofseconds, butlet's considerfor a momentwhatthatmightactuallymeanbecauseit's ourinformationwe'reputtingoutthereinthiscaseinpictorialform, we'veneverusedSnapchat.
Whentaking a photo, you'reabletosee a screenlikethisandallowyourmessagetoexpireeitherneverorinfinitelymanysecondsfromnowor 1 to 10 secondssomewhereinbetween, afterwhichthephotoisdeleted.
Well, whatdoesthatmeanInthecontextoflastweek?
ThoseofyouwithnowbackgroundinsequelmighthopethatwhatSnapchatisdoingontheirserversisexecuting a querylikethisdeletefromsnapswhere I d equalssomething.
Didn't represented, reallyjustbyto, ah, youknow, sotwoeyes, a noseand a mouththatapparentlyresemblesmyparticularface.
ThiswasreallyeasytoDio, and I don't havetotellyouthesedaysthatifyou'reonsocialmedia, allofushaveprobablybeenuploadingorhavehaduploadonourbehalfphotographsofusthatarethentagandwehaveforbetterforworse, beenjusttellingtheworldwhatwelooklikefromallsortsofangles.
Andhere, toointhedataperhapsbemisused.
Yes, it's wonderfullyusefulwhenyouuploadanalbumbecauseyourfriendscanseeOh, thatwas a greatnightouts.
CS 50 Zonewebsite, which, restassured, doesnotusethisfeature, but I canaddittoitinrealtime.
Here, seehisfiftieswebsiteatthemoment, andjustas I canviewdevelopertoolsbeforetoseethenetworktab, I canalsodothistovisitwhat's called a consul.
Solongstoryshort, thereisanabilityinbrowserstoruncodein a languagecalledJavascript.
It's anotherprogramminglanguage, similarandspirits, a pythonandthelike.
Butit's verycommonlyusedinbrowserstodayandthislittleprompthere, thelittlecarrotsymbolmeans I cantypeanything I want.
Nowthere's multiplewaystoaddcodeto a website, andifyoupursuesociety's Webtrack, you'llsee a numberoftheseways.
Butfornow, I'm gonnagoaheadandjustdo a simpleexamplebyrunningcodetosuggestjusthoweasyitisfor a websitetoaskthesamequestionthatyou'reabouttoseethatquestionbeing.
Ofcourse, youmighthavevisited a websiteandseeingsomethinglikethis a littlepopupsomewhatinnocuously, maybetoplefthandcornerofthescreen, youclickit, andthen, whilelaw, somefoodorderingwebsiteknowswhereyouareandsotheycangiveyouthemenusinthelocationorsomemapmightdisappear.