Lines 656-662
class _BcryptBackend(_BcryptCommon):
Link Here
|
656 |
assert isinstance(hash, bytes) |
656 |
assert isinstance(hash, bytes) |
657 |
if not hash.startswith(config) or len(hash) != len(config)+31: |
657 |
if not hash.startswith(config) or len(hash) != len(config)+31: |
658 |
raise uh.exc.CryptBackendError(self, config, hash, source="`bcrypt` package") |
658 |
raise uh.exc.CryptBackendError(self, config, hash, source="`bcrypt` package") |
659 |
return hash[-31:].decode("ascii") |
659 |
return hash[-31:] |
660 |
|
660 |
|
661 |
#----------------------------------------------------------------------- |
661 |
#----------------------------------------------------------------------- |
662 |
# bcryptor backend |
662 |
# bcryptor backend |
Lines 759-768
class _PyBcryptBackend(_BcryptCommon):
Link Here
|
759 |
# hash encoded as ascii bytes, returns ascii unicode. |
759 |
# hash encoded as ascii bytes, returns ascii unicode. |
760 |
secret, ident = self._prepare_digest_args(secret) |
760 |
secret, ident = self._prepare_digest_args(secret) |
761 |
config = self._get_config(ident) |
761 |
config = self._get_config(ident) |
762 |
hash = _pybcrypt.hashpw(secret, config) |
762 |
hash = _pybcrypt.hashpw(secret, config.encode('ascii')) |
763 |
if not hash.startswith(config) or len(hash) != len(config) + 31: |
763 |
if not hash.startswith(config.encode('ascii')) or len(hash) != len(config) + 31: |
764 |
raise uh.exc.CryptBackendError(self, config, hash, source="pybcrypt library") |
764 |
raise uh.exc.CryptBackendError(self, config, hash, source="pybcrypt library") |
765 |
return str_to_uascii(hash[-31:]) |
765 |
return hash[-31:] |
766 |
|
766 |
|
767 |
_calc_checksum = _calc_checksum_raw |
767 |
_calc_checksum = _calc_checksum_raw |
768 |
|
768 |
|
Lines 862-868
class _BuiltinBackend(_BcryptCommon):
Link Here
|
862 |
secret, ident = self._prepare_digest_args(secret) |
862 |
secret, ident = self._prepare_digest_args(secret) |
863 |
chk = _builtin_bcrypt(secret, ident[1:-1], |
863 |
chk = _builtin_bcrypt(secret, ident[1:-1], |
864 |
self.salt.encode("ascii"), self.rounds) |
864 |
self.salt.encode("ascii"), self.rounds) |
865 |
return chk.decode("ascii") |
865 |
return chk |
866 |
|
866 |
|
867 |
#============================================================================= |
867 |
#============================================================================= |
868 |
# handler |
868 |
# handler |