NEVER Handle Passwords Like THIS In Python...

Поделиться
HTML-код
  • Опубликовано: 24 сен 2024

Комментарии • 194

  • @chikkeneaten
    @chikkeneaten Год назад +402

    It's also good to store the password as a hash instead of the actual string.

    • @MrEnder0001
      @MrEnder0001 Год назад +11

      Could there be multiple passwords with the same has though?

    • @XYZaffair0
      @XYZaffair0 Год назад +47

      @@MrEnder0001Technically yes, but if you use a good hashing algorithm, it will almost never happen in practical use. Good algorithms make it take years and years of computing time to find two inputs with a matching hash, so there's no major security risk.

    • @farhanaditya2647
      @farhanaditya2647 Год назад +1

      @@XYZaffair0 but good in the sense of security isn't necessarily good in general. If the algorithm is too good, it might take too long to compute the hash.

    • @Bobtheconqueror42
      @Bobtheconqueror42 Год назад +1

      that was the first thing i noticed

    • @JontyCawleyGraham
      @JontyCawleyGraham Год назад +21

      Yes, if two people have the same password, it will produce the same hash. You should also include a salt, unique to the user to prevent two users having the same hash and prevent rainbow attacks on the hashes. Also, you should only use hashing algorithm specifically made for passwords to store password in (for example, argon2, bcrypt). Storing a password in a hash like SHA256 or even worse, MD5, can be cracked very quickly.

  • @salemyaslem9792
    @salemyaslem9792 Год назад +293

    How to make facebook?
    from facebook import facebook
    facebook()

    • @samueljehanno
      @samueljehanno Год назад +2

      😂

    • @AragamiMusic
      @AragamiMusic Год назад

      yes

    • @TheFreeSpiritKID
      @TheFreeSpiritKID Год назад

      Exactly hahah

    • @yourmama5055
      @yourmama5055 Год назад +14

      @@Violet-jg5oh who is forcing you to use the libraries

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад +7

      ​@@Violet-jg5oh You can still make everything from scratch tho. Libraries in general are preferred because they are tested and generally faster. They take care of the implementation. So that you, for example, don't have to implement TCP/IP with Sockets to make a "Hello World" API

  • @focat
    @focat Год назад +685

    "can you spot whats wrong with this code?"
    HE PUT A SPACE BEFORE THE COMMA MY OCD

    • @nuggets142
      @nuggets142 Год назад +11

      you would hate me

    • @floral1474
      @floral1474 Год назад +34

      no he didn't?

    • @ZantierTasa
      @ZantierTasa Год назад +5

      ​@@floral1474at the start of the short

    • @mariomicco5996
      @mariomicco5996 Год назад +28

      you have to separate the words so a space is good

    • @ZantierTasa
      @ZantierTasa Год назад +15

      ​@@mariomicco5996 But this line inserts 2 spaces:
      print("You typed: ", pwd)

  • @georgiostsakoumakis7754
    @georgiostsakoumakis7754 Год назад +38

    Another good measure is using a separate module to get the password then use getters to access it if necessary.

  • @notabdotawfik
    @notabdotawfik Год назад +25

    Bro named his variable "print working directory"

    • @jwcfive7999
      @jwcfive7999 Год назад

      PassWorD, pwd. P in pass, W in word, D in word

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      LOL i also though that

    • @austinglander1337
      @austinglander1337 5 месяцев назад

      For the better part of a decade I thought pwd meant present working directory… my mind is blown.

  • @atomicspartan131
    @atomicspartan131 Год назад +104

    I think I’m misunderstanding something here. If you don’t want to echo the password, just don’t print out what you’ve input??

    • @uKaigo
      @uKaigo Год назад +57

      He's talking about it being echoed while typing, the visual feedback. getpass avoid this by leaving it blank (so someone behind can't see what you're typing).
      Printing it is just an example, to show that the password is indeed being captured

    • @atomicspartan131
      @atomicspartan131 Год назад +13

      @@uKaigo ohhhhh that makes sense. Mind you, I watched this in the middle of the night so I was not comprehending what was being said lol

    • @uKaigo
      @uKaigo Год назад +2

      @@atomicspartan131 can relate lol

    • @Muescha
      @Muescha Год назад +3

      the important part is the input code - the output is just to show you that it still gets the password from the user with the other code

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      ​@@uKaigo It's not so much about the person behind you. Malware could very easily insert a reverse proxy into your stdin. Being able to read everything that the console prints and sent it somewhere else.
      That's why your SUDO password works just like this for example

  • @PaulO-ym5dm
    @PaulO-ym5dm Год назад +44

    why should you write passwords to standard output at all in the first place

  • @aidan-131
    @aidan-131 Год назад +20

    “What’s wrong with this code?” then says “use ___ library” 😂

    • @madbanana22
      @madbanana22 Год назад +4

      "oh so you made pong from scratch?"
      "stoopid, use import pong"

    • @iah
      @iah Год назад +3

      He's saying use one built in function instead of another one for this specific use case. Getpass is a built in module, it's not an external library...
      Regardless, it's not a good idea to implement your own password handling unless you have a deeper understanding of security. Better to use pre-existing code that's been developed with more security

    • @aidan-131
      @aidan-131 Год назад

      @@iah Thanks for the clarification! Hope this helps anyone! :)

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      ​@@iahDude absolutely. Specially taking into account that this type of behavior form the terminal is generally platform dependant. So it's cool to not have to worry about it

  • @ntlake
    @ntlake Год назад +15

    "Can you spot what's wrong with this code?"
    Me: he put the space in the string and then the comma, but the default value for sep is " ".

  • @samuelgunter
    @samuelgunter Год назад +2

    thought this was going to be "pwd is a built-in function, and naming a variable it here prevents you from using it later on and can mess up uses of it in this scope"

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      Nice tip. Tho preventing this issue is kinda the point of namespaces

  • @Cr4sHOv3rRiD3
    @Cr4sHOv3rRiD3 10 месяцев назад

    30 years ago I developed a code in GW BASIC which hides the input replacing it with star symbol everytime you hit the key. Those are true days of programming ;P

  • @joeman123964
    @joeman123964 Год назад +2

    well proper way is to use a database and query it. simply connect your code using a stored procedure with some arguments to pass.

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      What are you talking about? This is not a password for an API or a Web Service. The program already knows what the password SHOULD be. This is about not leaving said password hanging in the stdin/out (Standard Input/Output) of your machine

  • @MakinBacon0651
    @MakinBacon0651 Год назад +9

    There is nothing actually wrong with the code.

  • @additionaddict5524
    @additionaddict5524 Год назад +2

    If you’re learning how to do password security from a RUclips short you have no business asking for someone’s password

  • @ChhaviKewalramani
    @ChhaviKewalramani Год назад +8

    Great👍 I got to learn something new

  • @Germany-yw1kl
    @Germany-yw1kl Год назад +1

    Me, a C++ programmer: *interesting...*

  • @tank_tales
    @tank_tales 11 месяцев назад

    Brother how would you record shorts with figure windows in it?

  • @blue_tryhard3623
    @blue_tryhard3623 10 месяцев назад

    I also don't like the variable being named pwd cause in terminal window that will print your working directory.

  • @MarshTheBacca
    @MarshTheBacca 9 месяцев назад

    You could also use maskpass

  • @zareethanthegamer
    @zareethanthegamer 7 месяцев назад

    Why is echoing the password bad? It kinda pisses me off when programs DONT show me what im typing

  • @ojasbochare144
    @ojasbochare144 11 месяцев назад

    What does echo means ?

  • @TetyLike3
    @TetyLike3 Год назад +1

    ok but i didnt see this on the school powerpoint

  • @mr.k8660
    @mr.k8660 Год назад

    Can you replace the blanks by dots just like when type passwords in sites

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      That still documents the length of the password. Making brute forcing exponentially easier. For critical information you should give the least amount of information. That's why 'sudo' for example gets your password this way

  • @drku-_-9677
    @drku-_-9677 Год назад

    Whats a good Python code editor for a beginner?

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      Probably VSCode. But if you really are a beginner I would recommend doing as much as you can by hand without autocomplete and such. Will help you learn a lot faster by making it easier to make mistakes. Since mistakes are the best way to learn

  • @junkynioy
    @junkynioy Год назад +5

    How about echoing a * in place of .

    • @jakedeschamps4454
      @jakedeschamps4454 Год назад

      I forgot what the module was called, but once I did use a python module that I could use to mask input with whatever I wanted.

    • @aflous
      @aflous Год назад +1

      ​@@jakedeschamps4454it is pwinput

  • @exmodeus
    @exmodeus Год назад

    Just make an str subclass then override the str and repr dunder to return None or "****". This will prevent value conversion by str() and repr() but keeping the actual value remains the same.

    • @exmodeus
      @exmodeus Год назад

      For more context, the print() function will try to access the str dunder then the repr one if not exists.

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      The characters will still appear on screen when you call the input function. Which is what what getpass actually does. It, well, GETs the PASSword from stdin without echoing it
      Pretty clever idea, but it does NOT solve the issue

    • @exmodeus
      @exmodeus Год назад

      @@sebastiangudino9377 oh, I see. It's similar to msvcrt.getch.

  • @TrueMayo1
    @TrueMayo1 Год назад

    What font are you using

  • @alarii2582
    @alarii2582 Год назад +1

    >Just use this library lol
    I know this meant for beginners but the only useful information in this video is that you shouldn't echo passwords

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      It is good info tho. And actually getting input without aid input being on the screen is actually not trivial to implement in Python. And it's also platform dependant. So it makes sense why such a library exists

    • @alarii2582
      @alarii2582 Год назад

      @@sebastiangudino9377 I know why this library exists and I think people should use it if they need to but this is still a bad tutorial because it doesn't actually teach the viewer anything.

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      @@alarii2582 It's not a "Library" in the sense that it is part of the standard. The video is just teaching that instead of using input (A function that comes from the language) if you are dealing with passwords it is better to use getpass (Another function that comes with the language). Swaping one function for another makes your program more secure.
      While not groundbreaking, i think that's pretty useful to know for beginners. Specially since, again, this function is not easy to implement by yourself

  • @davidrivard1252
    @davidrivard1252 Год назад

    It should be common sense. There's also typically a bigger process for encrypting password. Atleast for secure applications.

  • @ChrizSee
    @ChrizSee Год назад +1

    "can you spot whats wrong with this code?"
    there are no semicolons

    • @Indently
      @Indently  Год назад

      Is this the first time you see Python? JavaScript is going to blow your mind then 😉

    • @catthebutcher9438
      @catthebutcher9438 Год назад

      ​@@Indently python is the definition of mistake 😂

    • @minoupower554
      @minoupower554 11 месяцев назад

      why?@@catthebutcher9438

  • @jumbopopcorn8979
    @jumbopopcorn8979 Год назад +4

    Is there a way to implement this in pure python?

    • @Indently
      @Indently  Год назад +3

      Could you be more specific? Everything I showed in the video was provided by vanilla Python.

    • @jumbopopcorn8979
      @jumbopopcorn8979 Год назад +8

      @@Indently Oh, I meant the package. How does it work?

    • @hak0bu
      @hak0bu Год назад +8

      ​@@Indently I was wondering about that too. No need to re-invent the wheel of course, but studying the invention of the wheel can bring some great ideas.
      I want to see how this is done without importing a module.
      This also applies for the other shorts, I think people will learn a lot if at the end you explain inner workings of the module that was imported.

    • @JorgeLuis-ts6qp
      @JorgeLuis-ts6qp Год назад +1

      ​@@hak0bu that's false. Pandas is mainly written in C.

    • @gregoriopescucci4997
      @gregoriopescucci4997 Год назад +1

      @@hak0bu nope the vast majority is written in a lower level language, mostly C

  • @New_movies_club
    @New_movies_club Год назад

    Bro,,, how to install turtle library in phone

  • @thecomposerchanginggames5250
    @thecomposerchanginggames5250 Год назад +1

    I thought you were talking about not checking against sql injections. I was way overthinking it 😄

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      This is not connecting to a db. This is for local programs. Well, for password input in general, regardless of where the information is stored

  • @teabags2day
    @teabags2day Год назад

    You heard the terminal! Subscribe my bois

  • @devon12346
    @devon12346 Год назад +1

    I registered for a forum and it sent me my password and username is clear text in an email

    • @alext5497
      @alext5497 Год назад

      A one time password?

    • @devon12346
      @devon12346 Год назад

      @@alext5497 no it was what i set it as

    • @alext5497
      @alext5497 Год назад

      @While you were reading this I stole your sandwich and donated it to a kid in africa time to change your passwords and don't use that site

    • @devon12346
      @devon12346 Год назад

      @@alext5497 oh it was a throwaway account anyways the password i set was obamafucker69 or something i dont use the same password for everything

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      This is why I'm becoming a fan of signing with Google instead. There I know my password is not getting anywhere near the shady websites, instead is safely stores inside the servers of a shady company

  • @Ortium
    @Ortium Год назад

    What theme is this

  • @PaulO-ym5dm
    @PaulO-ym5dm Год назад +1

    also if this is true and no bs to be able to invoke commands from a print function is not a good argument for python i guess

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      What do you even mean by "Invoking commanda from a print function"?

  • @gabrielmaimonie7005
    @gabrielmaimonie7005 Год назад

    Thanks very useful

  • @TheFreeSpiritKID
    @TheFreeSpiritKID Год назад

    What's wrong? You didn't use an f string, why would someone do that

  • @navoJ
    @navoJ Год назад +2

    how could we use * when someone typed password

    • @Muescha
      @Muescha Год назад +1

      i thought the same: would be nice to print star for every typed char

    • @puspamadak
      @puspamadak Год назад +2

      getpass module doesn't have that functionality, so you need to use another module, such as pwinput.
      Remember that printing asterisks can be a bad idea, since it will show the password length & can be used to speed up password cracking by hackers. So don't use it for any critical purpose.

    • @navoJ
      @navoJ Год назад +1

      @@puspamadak 99% of us will used it for some dumb app

  • @Fede_uyz
    @Fede_uyz Год назад

    heeeey, I'm named Federico!

  • @mr.bluesreadingclub6644
    @mr.bluesreadingclub6644 Год назад

    I would think they get password would Ask the user to enter the password twice since it’s not a code on the screen there’s a chance for mistakes if they only type at once.

    • @Indently
      @Indently  Год назад

      I can barely type my password correctly in once when logging in to any of my accounts (seriously, my password is more complicated than a UUID4 ID), if any system asked me twice to enter my password, I would never make it anywhere 😅
      But what you're saying makes sense for e-mails, but for passwords, if they get it wrong you tell them to try again and decrement the attempt count.

    • @mr.bluesreadingclub6644
      @mr.bluesreadingclub6644 Год назад

      @@Indently sure I get that but I figured the code was to create a new account or some type of connection. At least that’s my usual case and I ask for new passwords twice.

    • @Indently
      @Indently  Год назад

      If it's a new password, I understand :)

  • @davea136
    @davea136 10 месяцев назад

    There is nothing "wrong" with it. It runs fine and you specified no requirements at all.
    Your preference does not make a thing wrong. An engineer knows that.

  • @asprillahoulunai5847
    @asprillahoulunai5847 Год назад

    print(f"You type: {pswd}" was too easy?

  • @朋友是一个坚韧不-h8d
    @朋友是一个坚韧不-h8d Год назад

    Can we implement it without import any packages?

    • @unknownguywholovespizza
      @unknownguywholovespizza Год назад

      Yeah write yours. It's really easy

    • @iah
      @iah Год назад

      Getpass is built into python, it's not from pip or anything

    • @朋友是一个坚韧不-h8d
      @朋友是一个坚韧不-h8d Год назад

      @@iah i know, just curious about possibility of implement own Getpass without import any package

    • @catthebutcher9438
      @catthebutcher9438 Год назад

      ​@@朋友是一个坚韧不-h8d as Ibrahim typed under some other comment - you can create your own but you really have to know what you are doing if you want this to be secured. It is better to use already existing security functions that are verified.

  • @gx2244
    @gx2244 Год назад

    It's written in Python

  • @Wallee580
    @Wallee580 2 месяца назад

    Nah, I'd rather use raw input from STDIN. xD

  • @ImStian
    @ImStian Год назад

    What does it mean that the password gets echoed?

  • @evanbelcher
    @evanbelcher Год назад

    Don't do this either. Instead watch Tom Scott's computerphile video about why you should never code your own password form

  • @weird2765
    @weird2765 Год назад

    Ide?

  • @floboyyt
    @floboyyt 10 месяцев назад

    It’s not wrong.. you just should not do it like that.

  • @nsk8ter524
    @nsk8ter524 Год назад +1

    whats wrong with this code? its python

    • @Indently
      @Indently  Год назад

      I'm sure you could make a better programming language over a 3 week holiday

  • @typingforall
    @typingforall Год назад

    Good job

  • @Slowruner
    @Slowruner 9 месяцев назад

    Whats wrong use a f string

  • @Mr-Raptor
    @Mr-Raptor Год назад

    so nothing was wrong with the first code

  • @tr1p1ea
    @tr1p1ea Год назад

    ... why would you be printing out a password?

    • @Indently
      @Indently  Год назад

      Yes, ignore the valuable part of the video and concentrate on printing the password for demonstrational purposes

  • @sf4532
    @sf4532 Год назад +6

    hi

  • @imusinghuzuni
    @imusinghuzuni Год назад

    What app is this in?

  • @smjadeja4780
    @smjadeja4780 Год назад

    Anyone tell me the font

  • @Mingming_Studio
    @Mingming_Studio Год назад

    Good thing to know

  • @immortalsun
    @immortalsun 9 месяцев назад

    getpass is a function, not a method.

  • @likeitvverkir9207
    @likeitvverkir9207 Год назад +1

    What the difference between those methods?😊

    • @Muescha
      @Muescha Год назад

      the first response with the typed chars - so it reveal the password in console - the second don't echo the chars - so there is no way to see the password while you typing
      the print statement is there only to show that the second function gets also the password

  • @aaqibhamdule73
    @aaqibhamdule73 11 месяцев назад

    its pawwada not password

  • @vibheksoni8596
    @vibheksoni8596 Год назад

    😂 why not just set the text color to background color to hide text on any terminal

    • @catthebutcher9438
      @catthebutcher9438 Год назад

      Because it becomes visible after highlighting it with your mouse.

  • @colton75
    @colton75 Год назад

    Get pass is good

  • @markdavid9256
    @markdavid9256 Год назад

    But my dad got 115 but i got 126 😊

  • @unluckyaf7673
    @unluckyaf7673 Год назад

    Nothing is wrong with the code, the approach is bad

  • @craftrumzen2393
    @craftrumzen2393 Год назад

    Better use Java

  • @rV4nxZ
    @rV4nxZ Год назад

    Day 17 asking what IDE is he using

  • @matteodorighelli6133
    @matteodorighelli6133 Год назад +1

    Just use this library for a problem is not really creative content.

    • @Indently
      @Indently  Год назад +1

      Thanks for the feedback!

    • @matteodorighelli6133
      @matteodorighelli6133 Год назад +1

      @@Indently Don't worry I didn't mean to sound rude (even though I did a bit) but the introduced problem is more of something for people that already have some knowledge in python. Now you could either make such an input funcion by yourself or explain what getpass() really does more detailed. I think that way more people learn something new :)
      Btw I highly appreciate people explaining coding and making it more accessible for the general population. I think it's important that people know what their used functions do instead of just copying them from stack overflow. On work I saw way too many people doing this.

    • @sebastiangudino9377
      @sebastiangudino9377 Год назад

      ​@@matteodorighelli6133The thing is that getpass is impelentation dependant. It uses features specific to the terminal of the given platform.
      You could also just do it using c and functions like getch (Which ARE impelentation dependent as well lol).
      This is a video that shows a solution to a simple problem using a feature of the language (It's not even a "library" it's part of the standard library of the python language. I think is clearer to say that the getpass function that solves this problem is located on the getpass namespace in the standard library)

  • @woah-dude
    @woah-dude Год назад

    shame on you for not using types!

    • @Indently
      @Indently  Год назад +1

      I would love to use them 100% of the time, but they don't fit on the screen in shorts :)

    • @HandleNotAvailabIe
      @HandleNotAvailabIe Год назад

      ​@@Indently Are you Italian? I am and I've only heard "Federico" in italy

  • @FabioGamingFG
    @FabioGamingFG Год назад

    Python bad

  • @tawfiqkhalilieh1793
    @tawfiqkhalilieh1793 Год назад

    😂😂😂😂

  • @jbladesandsblazegaming
    @jbladesandsblazegaming Год назад +2

    The waffle house has found its new host

    • @Triggerblood
      @Triggerblood Год назад

      The Waffle House has found its new host

  • @rickdeckard4735
    @rickdeckard4735 Год назад

    import solution

  • @alexanderwan1534
    @alexanderwan1534 Год назад

    The waffle house has found it's new host

  • @pflasterstrips7254
    @pflasterstrips7254 Год назад

    So how to fix it:
    1. Just use this library that was made for this
    2. It won't work everywhere, but i guess it's better
    Lol, no

    • @justanothergunguy7146
      @justanothergunguy7146 Год назад +1

      It won’t work in the default Python REPL, which will never be used as a way for end users to access an application because it hands over complete control of the python environment. I don’t believe there is any solution that would work in the REPL and be cross platform, which is a pointless problem to solve anyways.