我在查找 python 模块时,发现了一个叫做“crypt”的东西。我不明白。我试过阅读这个,这是什么“盐”的东西,这个 crypt 模块的用途是什么,有没有某种方法可以将“crypt”应用于这段 python 代码?:
import crypt
max_attempts = 3
attempt = 0
try:
while attempt < max_attempts:
uname = input('Username: ')
password = input('pass: ')
if uname == 'admin' and password == 'Khs9':
print('Welcome Admin')
break
else:
attempt += 1
if attempt == max_attempts:
raise RuntimeError("\nYou've reached the maximum number of attempts allowed.")
else:
print('Wrong credentials.\n Try again or press <ctrl+c> to exit.\n')
continue
except KeyboardInterrupt:
print('Terminated by the user.\nGood-bye.')
except RuntimeError as e:
print("Goodbye")
Run Code Online (Sandbox Code Playgroud)