0

How to take input password ?

i mean like when we enter our password anywhere it appears as "*" . how can i take input like that?

25th Dec 2017, 8:35 PM
Arjun Saini
Arjun Saini - avatar
7 Answers
+ 5
You can use 'getpass' module for that. It doesn't show characters when typing: import getpass pwd = getpass.getpass('Enter your password: ') print('You set your password to:', pwd)
25th Dec 2017, 10:45 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 5
Then I think you have to write your own implementation with msvcrt or curses module (depending on your OS). https://docs.python.org/3/library/msvcrt.html https://docs.python.org/3.6/library/curses.html
26th Dec 2017, 8:03 AM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 5
@N0ob only via code comments for now :)
26th Dec 2017, 8:04 AM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 1
In a window or a terminal ? In a window, just do your own entry bar In a terminal, well .... I do not know ... set the terminal in no waiting for user input, and each time the user enter a character, enter \r ' ' so that you remove it I know how to do it in C on unix systems but not in Python
25th Dec 2017, 9:01 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
@Kuba I've tried that getpass... but it just makes whatever we write invisible. What i wanted to do is to make it look like '*****'.
26th Dec 2017, 6:38 AM
Arjun Saini
Arjun Saini - avatar