mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-01-31 03:36:41 +03:00
Add container usage for callable provider example
This commit is contained in:
parent
1eb9020a4e
commit
a497cb2527
|
@ -2,17 +2,22 @@
|
|||
|
||||
import passlib.hash
|
||||
|
||||
from dependency_injector import providers
|
||||
from dependency_injector import containers, providers
|
||||
|
||||
|
||||
password_hasher = providers.Callable(
|
||||
class Container(containers.DeclarativeContainer):
|
||||
|
||||
password_hasher = providers.Callable(
|
||||
passlib.hash.sha256_crypt.hash,
|
||||
salt_size=16,
|
||||
rounds=10000,
|
||||
)
|
||||
password_verifier = providers.Callable(passlib.hash.sha256_crypt.verify)
|
||||
)
|
||||
|
||||
password_verifier = providers.Callable(passlib.hash.sha256_crypt.verify)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
hashed_password = password_hasher('super secret')
|
||||
assert password_verifier('super secret', hashed_password)
|
||||
container = Container()
|
||||
|
||||
hashed_password = container.password_hasher('super secret')
|
||||
assert container.password_verifier('super secret', hashed_password)
|
||||
|
|
Loading…
Reference in New Issue
Block a user