METADATA 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. Metadata-Version: 2.1
  2. Name: bcrypt
  3. Version: 4.0.1
  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. Classifier: Development Status :: 5 - Production/Stable
  10. Classifier: License :: OSI Approved :: Apache Software License
  11. Classifier: Programming Language :: Python :: Implementation :: CPython
  12. Classifier: Programming Language :: Python :: Implementation :: PyPy
  13. Classifier: Programming Language :: Python :: 3
  14. Classifier: Programming Language :: Python :: 3 :: Only
  15. Classifier: Programming Language :: Python :: 3.6
  16. Classifier: Programming Language :: Python :: 3.7
  17. Classifier: Programming Language :: Python :: 3.8
  18. Classifier: Programming Language :: Python :: 3.9
  19. Classifier: Programming Language :: Python :: 3.10
  20. Requires-Python: >=3.6
  21. Description-Content-Type: text/x-rst
  22. License-File: LICENSE
  23. Provides-Extra: tests
  24. Requires-Dist: pytest (!=3.3.0,>=3.2.1) ; extra == 'tests'
  25. Provides-Extra: typecheck
  26. Requires-Dist: mypy ; extra == 'typecheck'
  27. bcrypt
  28. ======
  29. .. image:: https://img.shields.io/pypi/v/bcrypt.svg
  30. :target: https://pypi.org/project/bcrypt/
  31. :alt: Latest Version
  32. .. image:: https://github.com/pyca/bcrypt/workflows/CI/badge.svg?branch=main
  33. :target: https://github.com/pyca/bcrypt/actions?query=workflow%3ACI+branch%3Amain
  34. Acceptable password hashing for your software and your servers (but you should
  35. really use argon2id or scrypt)
  36. Installation
  37. ============
  38. To install bcrypt, simply:
  39. .. code:: bash
  40. $ pip install bcrypt
  41. Note that bcrypt should build very easily on Linux provided you have a C
  42. compiler and a Rust compiler (the minimum supported Rust version is 1.56.0).
  43. For Debian and Ubuntu, the following command will ensure that the required dependencies are installed:
  44. .. code:: bash
  45. $ sudo apt-get install build-essential cargo
  46. For Fedora and RHEL-derivatives, the following command will ensure that the required dependencies are installed:
  47. .. code:: bash
  48. $ sudo yum install gcc cargo
  49. For Alpine, the following command will ensure that the required dependencies are installed:
  50. .. code:: bash
  51. $ apk add --update musl-dev gcc cargo
  52. Alternatives
  53. ============
  54. While bcrypt remains an acceptable 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`_.
  55. Changelog
  56. =========
  57. 4.0.1
  58. -----
  59. * We now build PyPy ``manylinux`` wheels.
  60. * Fixed a bug where passing an invalid ``salt`` to ``checkpw`` could result in
  61. a ``pyo3_runtime.PanicException``. It now correctly raises a ``ValueError``.
  62. 4.0.0
  63. -----
  64. * ``bcrypt`` is now implemented in Rust. Users building from source will need
  65. to have a Rust compiler available. Nothing will change for users downloading
  66. wheels.
  67. * We no longer ship ``manylinux2010`` wheels. Users should upgrade to the latest
  68. ``pip`` to ensure this doesn’t cause issues downloading wheels on their
  69. platform. We now ship ``manylinux_2_28`` wheels for users on new enough platforms.
  70. * ``NUL`` bytes are now allowed in inputs.
  71. 3.2.2
  72. -----
  73. * Fixed packaging of ``py.typed`` files in wheels so that ``mypy`` works.
  74. 3.2.1
  75. -----
  76. * Added support for compilation on z/OS
  77. * The next release of ``bcrypt`` with be 4.0 and it will require Rust at
  78. compile time, for users building from source. There will be no additional
  79. requirement for users who are installing from wheels. Users on most
  80. platforms will be able to obtain a wheel by making sure they have an up to
  81. date ``pip``. The minimum supported Rust version will be 1.56.0.
  82. * This will be the final release for which we ship ``manylinux2010`` wheels.
  83. Going forward the minimum supported manylinux ABI for our wheels will be
  84. ``manylinux2014``. The vast majority of users will continue to receive
  85. ``manylinux`` wheels provided they have an up to date ``pip``.
  86. 3.2.0
  87. -----
  88. * Added typehints for library functions.
  89. * Dropped support for Python versions less than 3.6 (2.7, 3.4, 3.5).
  90. * Shipped ``abi3`` Windows wheels (requires pip >= 20).
  91. 3.1.7
  92. -----
  93. * Set a ``setuptools`` lower bound for PEP517 wheel building.
  94. * We no longer distribute 32-bit ``manylinux1`` wheels. Continuing to produce
  95. them was a maintenance burden.
  96. 3.1.6
  97. -----
  98. * Added support for compilation on Haiku.
  99. 3.1.5
  100. -----
  101. * Added support for compilation on AIX.
  102. * Dropped Python 2.6 and 3.3 support.
  103. * Switched to using ``abi3`` wheels for Python 3. If you are not getting a
  104. wheel on a compatible platform please upgrade your ``pip`` version.
  105. 3.1.4
  106. -----
  107. * Fixed compilation with mingw and on illumos.
  108. 3.1.3
  109. -----
  110. * Fixed a compilation issue on Solaris.
  111. * Added a warning when using too few rounds with ``kdf``.
  112. 3.1.2
  113. -----
  114. * Fixed a compile issue affecting big endian platforms.
  115. * Fixed invalid escape sequence warnings on Python 3.6.
  116. * Fixed building in non-UTF8 environments on Python 2.
  117. 3.1.1
  118. -----
  119. * Resolved a ``UserWarning`` when used with ``cffi`` 1.8.3.
  120. 3.1.0
  121. -----
  122. * Added support for ``checkpw``, a convenience method for verifying a password.
  123. * Ensure that you get a ``$2y$`` hash when you input a ``$2y$`` salt.
  124. * Fixed a regression where ``$2a`` hashes were vulnerable to a wraparound bug.
  125. * Fixed compilation under Alpine Linux.
  126. 3.0.0
  127. -----
  128. * Switched the C backend to code obtained from the OpenBSD project rather than
  129. openwall.
  130. * Added support for ``bcrypt_pbkdf`` via the ``kdf`` function.
  131. 2.0.0
  132. -----
  133. * Added support for an adjustible prefix when calling ``gensalt``.
  134. * Switched to CFFI 1.0+
  135. Usage
  136. -----
  137. Password Hashing
  138. ~~~~~~~~~~~~~~~~
  139. Hashing and then later checking that a password matches the previous hashed
  140. password is very simple:
  141. .. code:: pycon
  142. >>> import bcrypt
  143. >>> password = b"super secret password"
  144. >>> # Hash a password for the first time, with a randomly-generated salt
  145. >>> hashed = bcrypt.hashpw(password, bcrypt.gensalt())
  146. >>> # Check that an unhashed password matches one that has previously been
  147. >>> # hashed
  148. >>> if bcrypt.checkpw(password, hashed):
  149. ... print("It Matches!")
  150. ... else:
  151. ... print("It Does not Match :(")
  152. KDF
  153. ~~~
  154. As of 3.0.0 ``bcrypt`` now offers a ``kdf`` function which does ``bcrypt_pbkdf``.
  155. This KDF is used in OpenSSH's newer encrypted private key format.
  156. .. code:: pycon
  157. >>> import bcrypt
  158. >>> key = bcrypt.kdf(
  159. ... password=b'password',
  160. ... salt=b'salt',
  161. ... desired_key_bytes=32,
  162. ... rounds=100)
  163. Adjustable Work Factor
  164. ~~~~~~~~~~~~~~~~~~~~~~
  165. One of bcrypt's features is an adjustable logarithmic work factor. To adjust
  166. the work factor merely pass the desired number of rounds to
  167. ``bcrypt.gensalt(rounds=12)`` which defaults to 12):
  168. .. code:: pycon
  169. >>> import bcrypt
  170. >>> password = b"super secret password"
  171. >>> # Hash a password for the first time, with a certain number of rounds
  172. >>> hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
  173. >>> # Check that a unhashed password matches one that has previously been
  174. >>> # hashed
  175. >>> if bcrypt.checkpw(password, hashed):
  176. ... print("It Matches!")
  177. ... else:
  178. ... print("It Does not Match :(")
  179. Adjustable Prefix
  180. ~~~~~~~~~~~~~~~~~
  181. Another one of bcrypt's features is an adjustable prefix to let you define what
  182. libraries you'll remain compatible with. To adjust this, pass either ``2a`` or
  183. ``2b`` (the default) to ``bcrypt.gensalt(prefix=b"2b")`` as a bytes object.
  184. As of 3.0.0 the ``$2y$`` prefix is still supported in ``hashpw`` but deprecated.
  185. Maximum Password Length
  186. ~~~~~~~~~~~~~~~~~~~~~~~
  187. The bcrypt algorithm only handles passwords up to 72 characters, any characters
  188. beyond that are ignored. To work around this, a common approach is to hash a
  189. password with a cryptographic hash (such as ``sha256``) and then base64
  190. encode it to prevent NULL byte problems before hashing the result with
  191. ``bcrypt``:
  192. .. code:: pycon
  193. >>> password = b"an incredibly long password" * 10
  194. >>> hashed = bcrypt.hashpw(
  195. ... base64.b64encode(hashlib.sha256(password).digest()),
  196. ... bcrypt.gensalt()
  197. ... )
  198. Compatibility
  199. -------------
  200. This library should be compatible with py-bcrypt and it will run on Python
  201. 3.6+, and PyPy 3.
  202. C Code
  203. ------
  204. This library uses code from OpenBSD.
  205. Security
  206. --------
  207. ``bcrypt`` follows the `same security policy as cryptography`_, if you
  208. identify a vulnerability, we ask you to contact us privately.
  209. .. _`same security policy as cryptography`: https://cryptography.io/en/latest/security.html
  210. .. _`standard library`: https://docs.python.org/3/library/hashlib.html#hashlib.scrypt
  211. .. _`argon2_cffi`: https://argon2-cffi.readthedocs.io
  212. .. _`cryptography`: https://cryptography.io/en/latest/hazmat/primitives/key-derivation-functions/#cryptography.hazmat.primitives.kdf.scrypt.Scrypt