Argon2 won the Password Hashing Competition and argon2-cffi is the simplest way to use it in Python and PyPy:
>>> from argon2 import PasswordHasher
>>> ph = PasswordHasher()
>>> hash = ph.hash("correct horse battery staple")
>>> hash # doctest: +SKIP
'$argon2id$v=19$m=65536,t=3,p=4$MIIRqgvgQbgj220jfp0MPA$YfwJSVjtjSU0zzV/P3S9nnQ/USre2wvJMjfCIjrTQbg'
>>> ph.verify(hash, "correct horse battery staple")
True
>>> ph.check_needs_rehash(hash)
False
>>> ph.verify(hash, "Tr0ub4dor&3")
Traceback (most recent call last):
...
argon2.exceptions.VerifyMismatchError: The password does not match the supplied hash
- License: MIT
- PyPI: https://pypi.org/project/argon2-cffi/
- Source Code: https://github.com/hynek/argon2-cffi
- Documentation: https://argon2-cffi.readthedocs.io/
- Changelog: https://github.com/hynek/argon2-cffi/blob/main/CHANGELOG.md
- Supported Python Versions: 3.7 and later
The low-level Argon2 CFFI bindings are maintained in the separate argon2-cffi-bindings project.
Available as part of the Tidelift Subscription.
The maintainers of argon2-cffi and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open-source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.