进行md5加密。
import hashlib
obj = hashlib.md5('12121'.encode(('utf-8')))
obj.update("6666".encode('utf-8'))
mi = obj.hexdigest()
print(mi)
输入账号,密码,对密码进行md5加密后存储再test.txt。 后将账号,加密后的密码存储在test.txt里
import hashlib
def func(username, password):
obj = hashlib.md5(username.encode(('utf-8')))
obj.update(password.encode('utf-8'))
mi = obj.hexdigest()
return mi
username = input('Please Input Your Account: ')
password = input('Please Input Your Password: ')
password = func(username, password)
with open('test.txt', mode='w',encoding='utf-8') as fp:
fp.write('username:' + username + " ")
fp.write('password:' + password)
文件夹里显示:
username:admin password:a66abb5684c45962d887564f08346e8d
在查找时,先对密码进行加密,之后再和数据库里的加密密码比较。
|