METADATA 10 KB

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