]> granicus.if.org Git - python/commitdiff
Docs: correct hashlib.blake2 keyed hashing example (bpo-31560)
authorDmitry Chestnykh <dmitry@codingrobots.com>
Sat, 23 Sep 2017 17:18:40 +0000 (19:18 +0200)
committerBenjamin Peterson <benjamin@python.org>
Sat, 23 Sep 2017 17:18:40 +0000 (10:18 -0700)
Doc/library/hashlib.rst
Doc/tools/susp-ignored.csv

index 725dce6fa15f0fc5f96703d1dac2ede7470d5ea2..3a27a5b566f58dad62ce605e8923f06e2899cf3b 100644 (file)
@@ -510,15 +510,19 @@ to users and later verify them to make sure they weren't tampered with::
     ...     h.update(cookie)
     ...     return h.hexdigest().encode('utf-8')
     >>>
-    >>> cookie = b'user:vatrogasac'
+    >>> def verify(cookie, sig):
+    ...     good_sig = sign(cookie)
+    ...     return compare_digest(good_sig, sig)
+    >>>
+    >>> cookie = b'user-alice'
     >>> sig = sign(cookie)
     >>> print("{0},{1}".format(cookie.decode('utf-8'), sig))
-    user:vatrogasac,349cf904533767ed2d755279a8df84d0
-    >>> compare_digest(cookie, sig)
+    user-alice,b'43b3c982cf697e0c5ab22172d1ca7421'
+    >>> verify(cookie, sig)
     True
-    >>> compare_digest(b'user:policajac', sig)
+    >>> verify(b'user-bob', sig)
     False
-    >>> compare_digest(cookie, b'0102030405060708090a0b0c0d0e0f00')
+    >>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')
     False
 
 Even though there's a native keyed hashing mode, BLAKE2 can, of course, be used
index 7f1f9ea162934823a7a979ef18574b30d8929a55..2b3ccf3ac607000f8e4df3deb478f6d9f157107c 100644 (file)
@@ -130,9 +130,6 @@ library/exceptions,,:err,err.object[err.start:err.end]
 library/functions,,:step,a[start:stop:step]
 library/functions,,:stop,"a[start:stop, i]"
 library/functions,,:stop,a[start:stop:step]
-library/hashlib,,:vatrogasac,>>> cookie = b'user:vatrogasac'
-library/hashlib,,:vatrogasac,"user:vatrogasac,349cf904533767ed2d755279a8df84d0"
-library/hashlib,,:policajac,">>> compare_digest(b'user:policajac', sig)"
 library/hashlib,,:LEAF,"h00 = blake2b(buf[0:LEAF_SIZE], fanout=FANOUT, depth=DEPTH,"
 library/http.client,,:port,host:port
 library/http.cookies,,`,!#$%&'*+-.^_`|~: