METADATA 5.9 KB

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