-1

what I am trying to do is a command line sign in. The user puts in their credentials like this:

username = str(input('Username: '))
password = str(input('Password: '))

However, when they put in the password, I want it to be hashed on the command line. So for example, they type in "Password" with their keyboard, and that is how the program recognizes it, but on their screen it is hashed to be ********, so they can't see their own password like on a lot of websites. However, I can't find any way to do this. How would you go about doing this?

solar
  • 19
  • 2
  • 1
    [`getpass()`](https://docs.python.org/3/library/getpass.html#getpass.getpass) – Olvin Roght May 11 '21 at 13:27
  • 3
    To maintain the quality of the site, Stack Overflow doesn't permit duplicate questions. Please use the search function or your preferred search engine to research your issue before posting a new question. This is a duplicate of [Getting command-line password input in Python](https://stackoverflow.com/questions/9202224/getting-command-line-password-input-in-python) – esqew May 11 '21 at 13:28

1 Answers1

1

Install stdiomask

pip install stdiomask

Then:

import stdiomask

pwd = stdiomask.getpass()

You can use options such as:

stdiomask.getpass(prompt='pwd: ')

stdiomask.getpass(mask='x')
Synthase
  • 5,849
  • 2
  • 12
  • 34