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

[tor-commits] [stem/master] Standardize on hexlify() and unhexlify()



commit 9311858f3aa5a10c05dc3143ab925b1ed29324da
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Mar 21 21:46:29 2017 +0100

    Standardize on hexlify() and unhexlify()
    
    The binascii module have both these and aliases. Simpler if we standardize our
    codebase on using one.
---
 stem/descriptor/router_status_entry.py | 2 +-
 stem/response/authchallenge.py         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/stem/descriptor/router_status_entry.py b/stem/descriptor/router_status_entry.py
index 880051b..3cdb4ed 100644
--- a/stem/descriptor/router_status_entry.py
+++ b/stem/descriptor/router_status_entry.py
@@ -368,7 +368,7 @@ def _base64_to_hex(identity, check_if_fingerprint = True):
   except (TypeError, binascii.Error):
     raise ValueError("Unable to decode identity string '%s'" % identity)
 
-  fingerprint = binascii.b2a_hex(identity_decoded).upper()
+  fingerprint = binascii.hexlify(identity_decoded).upper()
 
   if stem.prereq.is_python_3():
     fingerprint = stem.util.str_tools._to_unicode(fingerprint)
diff --git a/stem/response/authchallenge.py b/stem/response/authchallenge.py
index d77fd81..94e406f 100644
--- a/stem/response/authchallenge.py
+++ b/stem/response/authchallenge.py
@@ -41,7 +41,7 @@ class AuthChallengeResponse(stem.response.ControlMessage):
       if not stem.util.tor_tools.is_hex_digits(value, 64):
         raise stem.ProtocolError('SERVERHASH has an invalid value: %s' % value)
 
-      self.server_hash = binascii.a2b_hex(stem.util.str_tools._to_bytes(value))
+      self.server_hash = binascii.unhexlify(stem.util.str_tools._to_bytes(value))
     else:
       raise stem.ProtocolError('Missing SERVERHASH mapping: %s' % line)
 
@@ -51,6 +51,6 @@ class AuthChallengeResponse(stem.response.ControlMessage):
       if not stem.util.tor_tools.is_hex_digits(value, 64):
         raise stem.ProtocolError('SERVERNONCE has an invalid value: %s' % value)
 
-      self.server_nonce = binascii.a2b_hex(stem.util.str_tools._to_bytes(value))
+      self.server_nonce = binascii.unhexlify(stem.util.str_tools._to_bytes(value))
     else:
       raise stem.ProtocolError('Missing SERVERNONCE mapping: %s' % line)



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