Question

I am looking for an example of an instance where we import the Python getpass library, enter our password, and the password does not echo to the terminal.

Here is an example where it does echo the password to the terminal:

$ python
>>> import getpass
>>> getpass.GetPassWarning
<class 'getpass.GetPassWarning'>
>>> getpass.getpass(stream=None)
Password:
'hello'
>>> 

Can someone give an example where it does not echo to the terminal?

Thanks!

Was it helpful?

Solution

You should write or save the password to a variable. Then the password will not be echoed. for example:

import getpass                                                                       

p=getpass.getpass("Enter the Password:")

Enter the Password:

print (p)

Output on console: pass@123

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top