METADATA 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. Metadata-Version: 2.1
  2. Name: bcrypt
  3. Version: 3.2.0
  4. Summary: Modern password hashing for your software and your servers
  5. Home-page: https://github.com/pyca/bcrypt/
  6. Author: The Python Cryptographic Authority developers
  7. Author-email: cryptography-dev@python.org
  8. License: Apache License, Version 2.0
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: License :: OSI Approved :: Apache Software License
  12. Classifier: Programming Language :: Python :: Implementation :: CPython
  13. Classifier: Programming Language :: Python :: Implementation :: PyPy
  14. Classifier: Programming Language :: Python :: 3
  15. Classifier: Programming Language :: Python :: 3.6
  16. Classifier: Programming Language :: Python :: 3.7
  17. Classifier: Programming Language :: Python :: 3.8
  18. Requires-Python: >=3.6
  19. Requires-Dist: cffi (>=1.1)
  20. Requires-Dist: six (>=1.4.1)
  21. Provides-Extra: tests
  22. Requires-Dist: pytest (!=3.3.0,>=3.2.1) ; extra == 'tests'
  23. Provides-Extra: typecheck
  24. Requires-Dist: mypy ; extra == 'typecheck'
  25. bcrypt
  26. ======
  27. .. image:: https://img.shields.io/pypi/v/bcrypt.svg
  28. :target: https://pypi.org/project/bcrypt/
  29. :alt: Latest Version
  30. .. image:: https://travis-ci.org/pyca/bcrypt.svg?branch=master
  31. :target: https://travis-ci.org/pyca/bcrypt
  32. .. image:: https://github.com/pyca/bcrypt/workflows/CI/badge.svg?branch=master
  33. :target: https://github.com/pyca/bcrypt/actions?query=workflow%3ACI+branch%3Amaster
  34. Good password hashing for your software and your servers
  35. Installation
  36. ============
  37. To install bcrypt, simply:
  38. .. code:: bash
  39. $ pip install bcrypt
  40. Note that bcrypt should build very easily on Linux provided you have a C compiler, headers for Python (if you're not using pypy), and headers for the libffi libraries available on your system.
  41. For Debian and Ubuntu, the following command will ensure that the required dependencies are installed:
  42. .. code:: bash
  43. $ sudo apt-get install build-essential libffi-dev python-dev
  44. For Fedora and RHEL-derivatives, the following command will ensure that the required dependencies are installed:
  45. .. code:: bash
  46. $ sudo yum install gcc libffi-devel python-devel
  47. For Alpine, the following command will ensure that the required dependencies are installed:
  48. .. code:: bash
  49. $ apk add --update musl-dev gcc libffi-dev
  50. Alternatives
  51. ============
  52. While bcrypt remains a good choice for password storage depending on your specific use case you may also want to consider using scrypt (either via `standard library`_ or `cryptography`_) or argon2id via `argon2_cffi`_.
  53. Changelog
  54. =========
  55. 3.2.0
  56. -----
  57. * Added typehints for library functions.
  58. * Dropped support for Python versions less than 3.6 (2.7, 3.4, 3.5).
  59. * Shipped ``abi3`` Windows wheels (requires pip >= 20).
  60. 3.1.7
  61. -----
  62. * Set a ``setuptools`` lower bound for PEP517 wheel building.
  63. * We no longer distribute 32-bit ``manylinux1`` wheels. Continuing to produce
  64. them was a maintenance burden.
  65. 3.1.6
  66. -----
  67. * Added support for compilation on Haiku.
  68. 3.1.5
  69. -----
  70. * Added support for compilation on AIX.
  71. * Dropped Python 2.6 and 3.3 support.
  72. * Switched to using ``abi3`` wheels for Python 3. If you are not getting a
  73. wheel on a compatible platform please upgrade your ``pip`` version.
  74. 3.1.4
  75. -----
  76. * Fixed compilation with mingw and on illumos.
  77. 3.1.3
  78. -----
  79. * Fixed a compilation issue on Solaris.
  80. * Added a warning when using too few rounds with ``kdf``.
  81. 3.1.2
  82. -----
  83. * Fixed a compile issue affecting big endian platforms.
  84. * Fixed invalid escape sequence warnings on Python 3.6.
  85. * Fixed building in non-UTF8 environments on Python 2.
  86. 3.1.1
  87. -----
  88. * Resolved a ``UserWarning`` when used with ``cffi`` 1.8.3.
  89. 3.1.0
  90. -----
  91. * Added support for ``checkpw``, a convenience method for verifying a password.
  92. * Ensure that you get a ``$2y$`` hash when you input a ``$2y$`` salt.
  93. * Fixed a regression where ``$2a`` hashes were vulnerable to a wraparound bug.
  94. * Fixed compilation under Alpine Linux.
  95. 3.0.0
  96. -----
  97. * Switched the C backend to code obtained from the OpenBSD project rather than
  98. openwall.
  99. * Added support for ``bcrypt_pbkdf`` via the ``kdf`` function.
  100. 2.0.0
  101. -----
  102. * Added support for an adjustible prefix when calling ``gensalt``.
  103. * Switched to CFFI 1.0+
  104. Usage
  105. -----
  106. Password Hashing
  107. ~~~~~~~~~~~~~~~~
  108. Hashing and then later checking that a password matches the previous hashed
  109. password is very simple:
  110. .. code:: pycon
  111. >>> import bcrypt
  112. >>> password = b"super secret password"
  113. >>> # Hash a password for the first time, with a randomly-generated salt
  114. >>> hashed = bcrypt.hashpw(password, bcrypt.gensalt())
  115. >>> # Check that an unhashed password matches one that has previously been
  116. >>> # hashed
  117. >>> if bcrypt.checkpw(password, hashed):
  118. ... print("It Matches!")
  119. ... else:
  120. ... print("It Does not Match :(")
  121. KDF
  122. ~~~
  123. As of 3.0.0 ``bcrypt`` now offers a ``kdf`` function which does ``bcrypt_pbkdf``.
  124. This KDF is used in OpenSSH's newer encrypted private key format.
  125. .. code:: pycon
  126. >>> import bcrypt
  127. >>> key = bcrypt.kdf(
  128. ... password=b'password',
  129. ... salt=b'salt',
  130. ... desired_key_bytes=32,
  131. ... rounds=100)
  132. Adjustable Work Factor
  133. ~~~~~~~~~~~~~~~~~~~~~~
  134. One of bcrypt's features is an adjustable logarithmic work factor. To adjust
  135. the work factor merely pass the desired number of rounds to
  136. ``bcrypt.gensalt(rounds=12)`` which defaults to 12):
  137. .. code:: pycon
  138. >>> import bcrypt
  139. >>> password = b"super secret password"
  140. >>> # Hash a password for the first time, with a certain number of rounds
  141. >>> hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
  142. >>> # Check that a unhashed password matches one that has previously been
  143. >>> # hashed
  144. >>> if bcrypt.checkpw(password, hashed):
  145. ... print("It Matches!")
  146. ... else:
  147. ... print("It Does not Match :(")
  148. Adjustable Prefix
  149. ~~~~~~~~~~~~~~~~~
  150. Another one of bcrypt's features is an adjustable prefix to let you define what
  151. libraries you'll remain compatible with. To adjust this, pass either ``2a`` or
  152. ``2b`` (the default) to ``bcrypt.gensalt(prefix=b"2b")`` as a bytes object.
  153. As of 3.0.0 the ``$2y$`` prefix is still supported in ``hashpw`` but deprecated.
  154. Maximum Password Length
  155. ~~~~~~~~~~~~~~~~~~~~~~~
  156. The bcrypt algorithm only handles passwords up to 72 characters, any characters
  157. beyond that are ignored. To work around this, a common approach is to hash a
  158. password with a cryptographic hash (such as ``sha256``) and then base64
  159. encode it to prevent NULL byte problems before hashing the result with
  160. ``bcrypt``:
  161. .. code:: pycon
  162. >>> password = b"an incredibly long password" * 10
  163. >>> hashed = bcrypt.hashpw(
  164. ... base64.b64encode(hashlib.sha256(password).digest()),
  165. ... bcrypt.gensalt()
  166. ... )
  167. Compatibility
  168. -------------
  169. This library should be compatible with py-bcrypt and it will run on Python
  170. 3.6+, and PyPy 3.
  171. C Code
  172. ------
  173. This library uses code from OpenBSD.
  174. Security
  175. --------
  176. ``bcrypt`` follows the `same security policy as cryptography`_, if you
  177. identify a vulnerability, we ask you to contact us privately.
  178. .. _`same security policy as cryptography`: https://cryptography.io/en/latest/security/
  179. .. _`standard library`: https://docs.python.org/3/library/hashlib.html#hashlib.scrypt
  180. .. _`argon2_cffi`: https://argon2-cffi.readthedocs.io
  181. .. _`cryptography`: https://cryptography.io/en/latest/hazmat/primitives/key-derivation-functions/#cryptography.hazmat.primitives.kdf.scrypt.Scrypt