6

How should I protect my password in Python 2.7? getpass.getpass() method is not working. At the time when I run my code, the password is visible.

I have done something like this:

M = imaplib.IMAP4_SSL('imap.gmail.com')

try:
     emailid=input("what is your email id: ")    
     password=getpass.getpass("enter your password: ")
     M.login(emailid,password)
Eric D
  • 6,901
  • 1
  • 15
  • 26
hussain
  • 769
  • 2
  • 7
  • 24
  • 1
    Doing a quick web search, the getpass() method you've already referenced is the only one anyone is referring to. Here is an example. http://stackoverflow.com/questions/1761744/python-read-password-from-stdin. Perhaps you could post your non working getpass() usage. – klog Dec 17 '15 at 05:44
  • passwd = fallback_getpass(prompt, stream) GetPassWarning: Can not control echo on the terminal. Warning: Password input may be echoed. this is what i m getting – hussain Dec 17 '15 at 05:47
  • [edit] your post to show the code for trying to use getpass – Arc676 Dec 17 '15 at 05:54
  • Does this answer your question? ["GetPassWarning: Can not control echo on the terminal" when running from IDLE](https://stackoverflow.com/questions/38878741/getpasswarning-can-not-control-echo-on-the-terminal-when-running-from-idle) – Karl Knechtel Aug 03 '22 at 03:10

1 Answers1

0

finally i got it. i used the method getpass.getpass(prompt='password=')

second thing is that this will only on run command prompt of a system(no third party application will give output for getpass.getpass())

hussain
  • 769
  • 2
  • 7
  • 24