|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
||||
|
||||
|
Password input?
How would I make the something inputed appear when being typed as * symbols, like a normal login deal.
I need to input passwords in a cmd line app I'm writing. Thanks.
__________________
Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes! |
|
#2
|
||||
|
||||
|
For a Windows console you can use the getch()/putch() pair found in the msvcrt module.
For Linux try the termios module. There is an example in it's documentation for password handling. Basically, this module allows you to switch options of the terminal the python app is running in. Grim |
|
#3
|
|||
|
|||
|
Or you could use the 'getpass' module. It seems it'll autodetect what you need with the getpass.getpass() function.
|
|
#4
|
||||
|
||||
|
Alright, I'll try that.
|
|
#5
|
||||
|
||||
|
That just seems too easy, there must be a catch
![]() |
|
#6
|
||||
|
||||
|
Believe it or not, no catch that i can see
.. tested and retested.. as long as you don't run though IDLE (which gives you a warning message) you wont see anything user enters! Kinda an invisable version of raw_input(), and very cross platform!A lil example, but too basic to be of any real use though! Code:
import getpass
passwd = getpass.getpass('enter your password')
raw_input('Press ENTER to show the password..')
print passwd
raw_input('Press ENTER to exit..')
Nicely spotted Perc Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Password input? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|