You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

239 regels
7.1 KiB

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