我在查找Python模块时发现了一个叫做“crypt”的东西,但是我不明白它是什么。我尝试阅读相关资料,但我不知道“salt”是什么意思、这个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")