2015-11-23 16:39:19 +03:00
|
|
|
"""`Callable` providers with keyword arguments example."""
|
2015-07-16 00:49:20 +03:00
|
|
|
|
2015-09-02 18:48:11 +03:00
|
|
|
import passlib.hash
|
2016-06-09 01:43:25 +03:00
|
|
|
|
2016-06-06 11:54:05 +03:00
|
|
|
import dependency_injector.providers as providers
|
2015-11-23 16:39:19 +03:00
|
|
|
|
2015-07-16 00:49:20 +03:00
|
|
|
|
2016-06-09 01:43:25 +03:00
|
|
|
# Password hasher and verifier providers:
|
2015-11-23 16:39:19 +03:00
|
|
|
password_hasher = providers.Callable(passlib.hash.sha256_crypt.encrypt,
|
|
|
|
salt_size=16,
|
|
|
|
rounds=10000)
|
|
|
|
password_verifier = providers.Callable(passlib.hash.sha256_crypt.verify)
|
2015-07-16 00:49:20 +03:00
|
|
|
|
2015-10-22 16:51:16 +03:00
|
|
|
# Making some asserts:
|
2015-07-16 02:39:21 +03:00
|
|
|
hashed_password = password_hasher('super secret')
|
|
|
|
assert password_verifier('super secret', hashed_password)
|