1

Is there any way of make python have a password input???

instead of:

Whats your password?
password     <--- this is a user input

I need:

Whats your password?
********     <--- this is a user input

Is that possible in python???

Panchi
  • 295
  • 1
  • 3
  • 12

1 Answers1

5

You can hide the input by using getpass:

import getpass

password = getpass.getpass("Whats your password?")
Ian Price
  • 7,416
  • 2
  • 23
  • 34
  • Is there a way of making it display asterisks??? – Panchi Feb 22 '16 at 19:25
  • No, though I believe the `curses` library can do that. However, displaying asterisks would be considered a vulnerability by some (least because it displays the number of characters the user has input). – Ian Price Feb 22 '16 at 19:28
  • 1
    you can also use tkinter, which definitely has a way to show other characters but it is a gui interface. Also look here http://stackoverflow.com/questions/10990998/how-to-have-password-echoed-as-asterisks – Jay T. Feb 22 '16 at 19:28
  • How would I do that @JayT. – Panchi Feb 22 '16 at 19:29
  • tkinter is a library for python that you can import and use, but as I already mentioned it is used to develop gui and I don't think can be used for command line. – Jay T. Feb 22 '16 at 19:32