问题
Currently I am making an image authentication project in which I need to authenticate an image with the help of a key. I am taking the key as a raw_input
from the user through the IPython console. I want to hide the key being entered.
Expected Result:
Enter the key = *****
or Enter the key = (nothing shown)
I found getpass()
method for hiding the entered data but it gives the following warning on my PC:
Warning: QtConsole does not support password mode, the text you type will be visible.
I even saw this code:
import sys
import msvcrt
passwor = ''
while True:
x = msvcrt.getch()
if x == '\r':
break
sys.stdout.write('*')
passwor +=x
print '\n'+passwor
But this prints infinite number of asterisks on the display.
Please let me know some solution for this problem.
来源:https://stackoverflow.com/questions/45814910/data-hiding-for-python-qtconsole