Ejemplo n.º 1
0
 def format(self, parsed_hash):
     """
     Takes a :class:`PasswordHash` instance and returns a byte string
     containing all information needed to verify a hash.
     """
     return b"$".join([
         native_to_bytes(parsed_hash.name),
         hexlify(parsed_hash.hash)
     ])
Ejemplo n.º 2
0
    def format(self, parsed_hash):
        """
        Takes a :class:`PasswordHash` object as returned by :meth:`parse` and
        returns a byte string that must be parseable by :meth:`parse`.

        The given hash object is expected to have a `salt` parameter of type
        `str`.
        """
        return b"$".join([
            native_to_bytes(parsed_hash.name),
            hexlify(parsed_hash.salt),
            hexlify(parsed_hash.hash)
        ])
Ejemplo n.º 3
0
    def format(self, parsed_hash):
        """
        Takes a :class:`PasswordHash` object as returned by :meth:`parse` and
        returns a byte string that must be parseable by :meth:`parse`.

        The given hash object is expected to have an `cost` parameter
        corresponding to the `cost` argument :class:`BCryptHasher` takes.
        """
        return b"$".join([
            native_to_bytes(parsed_hash.name),
            int_to_bytes(parsed_hash.cost),
            parsed_hash.hash
        ])
Ejemplo n.º 4
0
    def format(self, parsed_hash):
        """
        Takes a :class:`PasswordHash` object as returned by :meth:`parse` and
        returns a byte string that must be parseable by :meth:`parse`.

        The given hash object is expected to have a `rounds` and `method`
        parameter, corresponding to the arguments passed to
        :class:`PBKDF2Hasher` as well as a `salt` parameter of type `str`.
        """
        return b"$".join([
            native_to_bytes(parsed_hash.name),
            parsed_hash.method.encode("ascii"),
            int_to_bytes(parsed_hash.rounds),
            hexlify(parsed_hash.salt),
            hexlify(parsed_hash.hash)
        ])