import osimport timeimport randomimport sysimport stringimport hashlibusers = {}class User: def __init__(self, username, password): self.username = username self.password = passwordrunning = Truewhile running: os.system("cls") print("Welcome. Please register yourself.") print() uname = input("Username: ") pword = input("Password: ") users.update({"" + uname : "" + pword}) hash_object = hashlib.sha1(pword.encode()) pswrd = open("hash.txt", "a") pswrd.write(str(hash_object)) pswrd.close() for key, value in users.items(): print() print(key, " : ", value) time.sleep(3)当我打开文本文件时,它有这个:<sha1 HASH object @ 0x010E6600>我怎样才能防止这种情况?任何帮助是极大的赞赏!PS我知道将用户名和密码存储在字典中效率不高,但这是我现在唯一可以做到的方法。
1 回答
喵喵时光机
TA贡献1846条经验 获得超7个赞
您可能想要存储的不是哈希本身,而是它的 HEX 摘要:
hash_object.hexdigest() # 'dc7e6b79b489fa810e11889710023e7e2e36fb64'
添加回答
举报
0/150
提交
取消