summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-11-29 12:13:53 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-11-29 12:14:53 -0600
commit1994f9192ba4d29a5bb41954a77314b8280a8d0d (patch)
treed555c1ea1026533586d72cec95ef6bbc73473e5a
parent211b9a1862c4074024a9895c1764060e6903fa71 (diff)
downloadpy-bcrypt-git-1994f9192ba4d29a5bb41954a77314b8280a8d0d.tar.gz
provide a better explanation for what to do with long passwords
-rw-r--r--README.rst5
1 files changed, 3 insertions, 2 deletions
diff --git a/README.rst b/README.rst
index 2479dbb..a6708cf 100644
--- a/README.rst
+++ b/README.rst
@@ -89,14 +89,15 @@ Maxmimum Password Length
The bcrypt algorithm only handles passwords up to 72 characters, any characters
beyond that are ignored. To work around this, a common approach is to hash a
-password with a cryptographic hash, such as ``sha512`` before hasing it with
+password with a cryptographic hash (such as ``sha256``) and then hex or base64
+encoding it to prevent NULL byte problems before hashing the result with
``bcrypt``:
.. code:: pycon
>>> password = b"an incredibly long password" * 10
>>> hashed = bcrypt.hashpw(
- ... hashlib.sha512(password).digest(),
+ ... hashlib.sha256(password).hexdigest(),
... bcrypt.gensalt()
... )