import sys, tty, termios
def getch():
"""
Funcion para obtener un solo caracter por el teclado sin mostrarlo por
la pantalla
@return string caracter pulsado
"""
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
key = ""
sys.stdout.write('Password :: ')
while True:
ch = getch()
if ch == '\r':
break
key += ch
sys.stdout.write('*')
print(key)
Comentarios sobre la versión: Python 2.7 (0)
No hay comentarios