2

I've been trying to make a simple sign-up/in program and I wanted to hide the password, so I took to the internet.

I tried out this thing called getpass, but it didn't work. It just told me it couldn't change the echo in IDLE's shell.(I use IDLE Python 3.6 on Windows 10 btw)

So I was wondering if there's a way to hide the input without getpass, or to encrypt it some other way?

Here's the code:

class Account:
    def __init__(self, un, pw):
        self.un = un
        self.pw = pw

accounts = []

#account signing up

def signup():
    usernm = input("Make a username >>> ")
    passwd = input("Make a password >>> ")
    accounts.append(Account(usernm, passwd))

def signin():
    inun = input("Username? >>> ")
    inpw = input("Password >>> ")
    for account in accounts:
        if account.un == inun:
            if account.pw == inpw:
                print("Signed in!")



option = input("Sign [i]n or sign [u]p? >>> ").lower()
if option == "i":
    signin()
if option == "u":
    signup()

Thanks :)

petezurich
  • 9,280
  • 9
  • 43
  • 57

1 Answers1

0

The getpass completely works for me, so i would assume that you didnt used the correct syntax

import getpass
 
p = getpass.getpass(prompt='Enter Your password: ')

But if you are saying getpass didnt work because you cannot see any change in cursor, then you are wrong. getpass just shows an un-echoed password (means it wont send the key strokes the the terminal).

The Python IDLE or console meant for developing propose, not to use in program made for users. So I would recommend you to use some sort of GUI like Tkinter to fulfill you propose.

But if you want the cursor to move, there are 2 solution below:

  • For Python IDLE, use this Link.
  • For Tkinter, you can use Entry widget, try Entry(root, show="*"), this would show "*" for every key you enter.
Faraaz Kurawle
  • 1,085
  • 6
  • 24