def _calc_checksum(self, secret):
# bcrypt behavior:
# secret must be bytes
# config must be ascii bytes
# returns ascii bytes
secret, ident = self._prepare_digest_args(secret)
config = self._get_config(ident)
if isinstance(config, unicode):
config = config.encode("ascii")
hash = _bcrypt.hashpw(secret, config)
assert hash.startswith(config) and len(hash) == len(config)+31, \
"config mismatch: %r => %r" % (config, hash)
assert isinstance(hash, bytes)
return hash[-31:].decode("ascii")
#-----------------------------------------------------------------------
# bcryptor backend
#-----------------------------------------------------------------------
评论列表
文章目录