def password(self, pwd): ''' 对密码加盐 :param pwd: :return: ''' _salt = self._gen_salt() _save_pwd = horner_sha1((pwd + _salt).encode("utf-8")) self.pwd_salt = _salt self.pwd = _save_pwd
def checkPwd(self, pwd): ''' 检查密码是否匹配 :param pwd: 待检查的密码 :return: bool ''' _chk_pwd = horner_sha1((pwd + self.pwd_salt).encode("utf-8")) if _chk_pwd == self.pwd: return True else: return False