该
getpass模块是用Python编写的。您可以轻松地对其进行修改以执行此操作。实际上,这是它的修改版本
getpass.win_getpass(),您可以将其粘贴到代码中:
import sysdef win_getpass(prompt='Password: ', stream=None): """prompt for password with echo off, using Windows getch().""" import msvcrt for c in prompt: msvcrt.putch(c) pw = "" while 1: c = msvcrt.getch() if c == 'r' or c == 'n': break if c == ' 03': raise KeyboardInterrupt if c == 'b': pw = pw[:-1] msvcrt.putch('b') else: pw = pw + c msvcrt.putch("*") msvcrt.putch('r') msvcrt.putch('n') return pw但是,您可能需要重新考虑这一点。Linux方式更好;即使只是知道密码中的字符数,对于想要破解它的人来说也是一个重要的提示。



