July 18th, 2005, 05:53 PM
Scrambling passwords at login?
I'm looking around to find a way to replace password input with "***" or even completely mute the echo. I'd like to do it without using special ANSI codes (I tried the "no echo" code but it didn't work anyway).
Any ideas? I'm using the asyncore/asynchat modules. I'm afraid I'll have to rewrite the push() method.
July 19th, 2005, 02:09 AM
If you are using a text-only interface, you could try getpass.getpass() from the standard library. Try this test code to see if it is what you want:
This may give you problems in Windows, however. While it worked fine in the Windows Console itself, it wouldn't work in the DrPython or IDLE test windows; in the former it failed to work at all, while in the latter the prompt worked correctly but the text was echoed, and it gave a warning message.
# File: getpass-example-1.py
usr = getpass.getuser()
pwd = getpass.getpass("enter password for user %s: " % usr)
print usr, pwd
There is also a Console module available specifically for Windows which I believe provides the same functionality.
Last edited by Schol-R-LEA; July 19th, 2005 at 02:33 AM.