Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: DasIch/pwhash
base: 9fbe63e02f
...
head fork: DasIch/pwhash
compare: c20cbab1f9
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 23 additions and 0 deletions.
  1. +23 −0 pwhash/hashers.py
View
23 pwhash/hashers.py
@@ -229,6 +229,9 @@ 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),
@@ -322,6 +325,10 @@ 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),
@@ -441,6 +448,9 @@ 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),
@@ -533,6 +543,13 @@ def _create_from_bytes(self, password):
))
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),
@@ -540,6 +557,12 @@ def format(self, parsed_hash):
])
def parse(self, formatted_hash):
+ """
+ Parses a `formatted_hash` as returned by :meth:`format` and returns a
+ :class:`PasswordHash` object.
+
+ The returned hash object is expected to have a `salt` parameter.
+ """
salt, hash = UpgradeableHasher.parse(self, formatted_hash).split(b"$", 1)
return PasswordHash(self.name, hash, salt=unhexlify(salt))

No commit comments for this range

Something went wrong with that request. Please try again.