I tried many different getpass
style packages but they either didn't install properly or would't work.
The code below has been adapted from getpass3.
It requires the getch package and only runs under Python 3.
#/usr/bin/env python3
from getch import *
import sys
echo = '*'
def getpass(label):
print(label, end='', flush=True)
password = ''
while True:
inp = getch()
if inp == '\n':
break
elif inp == '\003':
raise KeyboardInterrupt
elif inp == '\04':
raise EOFError
else:
print(echo, end='', flush=True)
password += inp
print('')
return password
print(getpass("Password: "))
You could add python after the first three backticks to enable syntax highlighting