def _calc_checksum_pybcrypt(self, secret): #pybcrypt behavior: # py2: unicode secret -> ascii bytes (we override this) # unicode hash -> ascii bytes (we provide ascii bytes) # returns ascii bytes # py3: can't get to install if isinstance(secret, unicode): secret = secret.encode("utf-8") hash = pybcrypt_hashpw(secret, self.to_string(native=False)) return hash[-31:].decode("ascii")
def _calc_checksum_pybcrypt(self, secret): # py-bcrypt behavior: # py2: unicode secret/hash encoded as ascii bytes before use, # bytes taken as-is; returns ascii bytes. # py3: not supported (patch submitted) if isinstance(secret, unicode): secret = secret.encode("utf-8") if _BNULL in secret: raise uh.exc.NullPasswordError(self) config = self._get_config() hash = pybcrypt_hashpw(secret, config) assert hash.startswith(config) and len(hash) == len(config) + 31 return str_to_uascii(hash[-31:])
def _calc_checksum_pybcrypt(self, secret): # py-bcrypt behavior: # py2: unicode secret/hash encoded as ascii bytes before use, # bytes taken as-is; returns ascii bytes. # py3: not supported (patch submitted) if isinstance(secret, unicode): secret = secret.encode("utf-8") if _BNULL in secret: raise uh.exc.NullPasswordError(self) config = self._get_config() hash = pybcrypt_hashpw(secret, config) assert hash.startswith(config) and len(hash) == len(config)+31 return str_to_uascii(hash[-31:])