[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/develop] Pep8 and cleanup for bridgedb.Bridges.get_hmac_fn().



commit 9307ffbda3a7d0108edd6f078b9c9a934b675239
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Fri Mar 7 16:23:54 2014 +0000

    Pep8 and cleanup for bridgedb.Bridges.get_hmac_fn().
---
 lib/bridgedb/Bridges.py |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py
index 3d27ad1..cd77911 100644
--- a/lib/bridgedb/Bridges.py
+++ b/lib/bridgedb/Bridges.py
@@ -92,13 +92,17 @@ def get_hmac(key, value):
     h = hmac.new(key, value, digestmod=DIGESTMOD)
     return h.digest()
 
-def get_hmac_fn(k, hex=True):
+def get_hmac_fn(key, hex=True):
     """Return a function that computes the hmac of its input using the key k.
-       If 'hex' is true, the output of the function will be hex-encoded."""
-    h = hmac.new(k, digestmod=DIGESTMOD)
-    def hmac_fn(v):
+
+    :param bool hex: If True, the output of the function will be hex-encoded.
+    :rtype: callable
+    :returns: A function which can be uses to generate HMACs.
+    """
+    h = hmac.new(key, digestmod=DIGESTMOD)
+    def hmac_fn(value):
         h_tmp = h.copy()
-        h_tmp.update(v)
+        h_tmp.update(value)
         if hex:
             return h_tmp.hexdigest()
         else:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits