5

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.

Ambika Saxena
  • 215
  • 4
  • 17
  • 1
    `getpass` works out of Spyder. This is a limitation of Spyder/QtConsole, not of getpass itself. – Carlos Cordoba Aug 22 '17 at 18:41
  • @CarlosCordoba thanks. But do you know any function or code that could suffice my need? – Ambika Saxena Aug 24 '17 at 10:22
  • Not that will run inside Spyder. You can go to `Run > Configuration per file > Console` and select the option called `Execute in an external terminal` to use an external terminal instead. – Carlos Cordoba Aug 24 '17 at 19:56
  • Please see a workaround in linked question, and if you can, please add the Windows-specific basic GUI commands in Option 1. – Leo Mar 30 '20 at 00:55

0 Answers0