17 lines
397 B
Python
17 lines
397 B
Python
|
import hashlib
|
||
|
|
||
|
|
||
|
class Md5Util(object):
|
||
|
|
||
|
def __init__(self, *, salt: str, password: str):
|
||
|
self.salt = salt
|
||
|
self.password = password
|
||
|
|
||
|
def md5(self):
|
||
|
# 实例化对象, 加盐
|
||
|
obj = hashlib.md5(self.salt.encode('utf-8'))
|
||
|
# 加密密码
|
||
|
obj.update(self.password.encode('utf-8'))
|
||
|
# 提取密码,返回
|
||
|
return obj.hexdigest()
|