-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
437 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
coverage | ||
hypothesis | ||
hypothesis-pytest | ||
pytest | ||
wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
""" | ||
Legacy mid-level functions. | ||
""" | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
import os | ||
|
||
from ._util import Type | ||
|
||
from ._password_hasher import ( | ||
DEFAULT_HASH_LENGTH, | ||
DEFAULT_MEMORY_COST, | ||
DEFAULT_PARALLELISM, | ||
DEFAULT_RANDOM_SALT_LENGTH, | ||
DEFAULT_TIME_COST, | ||
) | ||
from .low_level import hash_secret, hash_secret_raw, verify_secret | ||
|
||
|
||
def hash_password(password, salt=None, | ||
time_cost=DEFAULT_TIME_COST, | ||
memory_cost=DEFAULT_MEMORY_COST, | ||
parallelism=DEFAULT_PARALLELISM, | ||
hash_len=DEFAULT_HASH_LENGTH, | ||
type=Type.I): | ||
""" | ||
Legacy alias for :func:`hash_secret` with default parameters. | ||
.. deprecated:: 16.0.0 | ||
Use :class:`PasswordHasher` for passwords. | ||
""" | ||
if salt is None: | ||
salt = os.urandom(DEFAULT_RANDOM_SALT_LENGTH) | ||
return hash_secret( | ||
password, salt, time_cost, memory_cost, parallelism, hash_len, type | ||
) | ||
|
||
|
||
def hash_password_raw(password, salt=None, | ||
time_cost=DEFAULT_TIME_COST, | ||
memory_cost=DEFAULT_MEMORY_COST, | ||
parallelism=DEFAULT_PARALLELISM, | ||
hash_len=DEFAULT_HASH_LENGTH, | ||
type=Type.I): | ||
""" | ||
Legacy alias for :func:`hash_secret_raw` with default parameters. | ||
.. deprecated:: 16.0.0 | ||
Use :class:`PasswordHasher` for passwords. | ||
""" | ||
if salt is None: | ||
salt = os.urandom(DEFAULT_RANDOM_SALT_LENGTH) | ||
return hash_secret_raw( | ||
password, salt, time_cost, memory_cost, parallelism, hash_len, type | ||
) | ||
|
||
|
||
def verify_password(hash, password, type=Type.I): | ||
""" | ||
Legacy alias for :func:`verify_secret` with default parameters. | ||
.. deprecated:: 16.0.0 | ||
Use :class:`PasswordHasher` for passwords. | ||
""" | ||
return verify_secret(hash, password, type) |
Oops, something went wrong.