5

Is there a way to protect user input by echoing asterisks ?

Or do i need to look at a different approach and use something aside from input().

Seems sloppy to have the user enter in their credentials without some rudimentary protection or consideration.

When using getpass I am then unable to authenticate to gmail.

Are there other considerations or some "unpacking" that needs to be done with pass=getpass.getpass('enter password')?

inbinder
  • 692
  • 4
  • 11
  • 28
  • 2
    LMGTFY: http://docs.python.org/2/library/getpass.html – Fred Foo Feb 03 '14 at 17:22
  • 1
    *“Are there other considerations or some ‘unpacking’ that needs to be done”* – No, `getpass` returns a string. You can print it out to check if the input was correct. Otherwise something else is failing. – poke Feb 03 '14 at 17:38

1 Answers1

5

Try the getpass module.

import getpass
mypass = getpass.getpass("Please enter your password:")

This does not echo the asterisks, but it does hide your typing, which is presumably the goal.

Kevin
  • 2,112
  • 14
  • 15