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.

205 lines
5.8 KiB

7 years ago
  1. Metadata-Version: 2.0
  2. Name: bcrypt
  3. Version: 3.1.4
  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 (>=3.2.1); 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.4
  47. -----
  48. * Fixed compilation with mingw and on illumos.
  49. 3.1.3
  50. -----
  51. * Fixed a compilation issue on Solaris.
  52. * Added a warning when using too few rounds with ``kdf``.
  53. 3.1.2
  54. -----
  55. * Fixed a compile issue affecting big endian platforms.
  56. * Fixed invalid escape sequence warnings on Python 3.6.
  57. * Fixed building in non-UTF8 environments on Python 2.
  58. 3.1.1
  59. -----
  60. * Resolved a ``UserWarning`` when used with ``cffi`` 1.8.3.
  61. 3.1.0
  62. -----
  63. * Added support for ``checkpw``, a convenience method for verifying a password.
  64. * Ensure that you get a ``$2y$`` hash when you input a ``$2y$`` salt.
  65. * Fixed a regression where ``$2a`` hashes were vulnerable to a wraparound bug.
  66. * Fixed compilation under Alpine Linux.
  67. 3.0.0
  68. -----
  69. * Switched the C backend to code obtained from the OpenBSD project rather than
  70. openwall.
  71. * Added support for ``bcrypt_pbkdf`` via the ``kdf`` function.
  72. 2.0.0
  73. -----
  74. * Added support for an adjustible prefix when calling ``gensalt``.
  75. * Switched to CFFI 1.0+
  76. Usage
  77. -----
  78. Password Hashing
  79. ~~~~~~~~~~~~~~~~
  80. Hashing and then later checking that a password matches the previous hashed
  81. password is very simple:
  82. .. code:: pycon
  83. >>> import bcrypt
  84. >>> password = b"super secret password"
  85. >>> # Hash a password for the first time, with a randomly-generated salt
  86. >>> hashed = bcrypt.hashpw(password, bcrypt.gensalt())
  87. >>> # Check that an unhashed password matches one that has previously been
  88. >>> # hashed
  89. >>> if bcrypt.checkpw(password, hashed):
  90. ... print("It Matches!")
  91. ... else:
  92. ... print("It Does not Match :(")
  93. KDF
  94. ~~~
  95. As of 3.0.0 ``bcrypt`` now offers a ``kdf`` function which does ``bcrypt_pbkdf``.
  96. This KDF is used in OpenSSH's newer encrypted private key format.
  97. .. code:: pycon
  98. >>> import bcrypt
  99. >>> key = bcrypt.kdf(
  100. ... password=b'password',
  101. ... salt=b'salt',
  102. ... desired_key_bytes=32,
  103. ... rounds=100)
  104. Adjustable Work Factor
  105. ~~~~~~~~~~~~~~~~~~~~~~
  106. One of bcrypt's features is an adjustable logarithmic work factor. To adjust
  107. the work factor merely pass the desired number of rounds to
  108. ``bcrypt.gensalt(rounds=12)`` which defaults to 12):
  109. .. code:: pycon
  110. >>> import bcrypt
  111. >>> password = b"super secret password"
  112. >>> # Hash a password for the first time, with a certain number of rounds
  113. >>> hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
  114. >>> # Check that a unhashed password matches one that has previously been
  115. >>> # hashed
  116. >>> if bcrypt.checkpw(password, hashed):
  117. ... print("It Matches!")
  118. ... else:
  119. ... print("It Does not Match :(")
  120. Adjustable Prefix
  121. ~~~~~~~~~~~~~~~~~
  122. Another one of bcrypt's features is an adjustable prefix to let you define what
  123. libraries you'll remain compatible with. To adjust this, pass either ``2a`` or
  124. ``2b`` (the default) to ``bcrypt.gensalt(prefix=b"2b")`` as a bytes object.
  125. As of 3.0.0 the ``$2y$`` prefix is still supported in ``hashpw`` but deprecated.
  126. Maximum Password Length
  127. ~~~~~~~~~~~~~~~~~~~~~~~
  128. The bcrypt algorithm only handles passwords up to 72 characters, any characters
  129. beyond that are ignored. To work around this, a common approach is to hash a
  130. password with a cryptographic hash (such as ``sha256``) and then base64
  131. encode it to prevent NULL byte problems before hashing the result with
  132. ``bcrypt``:
  133. .. code:: pycon
  134. >>> password = b"an incredibly long password" * 10
  135. >>> hashed = bcrypt.hashpw(
  136. ... base64.b64encode(hashlib.sha256(password).digest()),
  137. ... bcrypt.gensalt()
  138. ... )
  139. Compatibility
  140. -------------
  141. This library should be compatible with py-bcrypt and it will run on Python
  142. 2.6+, 3.3+, and PyPy 2.6+.
  143. C Code
  144. ------
  145. This library uses code from OpenBSD.
  146. Security
  147. --------
  148. ``bcrypt`` follows the `same security policy as cryptography`_, if you
  149. identify a vulnerability, we ask you to contact us privately.
  150. .. _`same security policy as cryptography`: https://cryptography.io/en/latest/security/

Powered by TurnKey Linux.