[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Provide unicode from to_base64()
commit c18daba11b00ce084b903a54c40551737b15bfe4
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Fri Oct 25 14:29:24 2019 -0700
Provide unicode from to_base64()
Standardizing our return type so unit tests pass with python3.
---
stem/descriptor/certificate.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/stem/descriptor/certificate.py b/stem/descriptor/certificate.py
index 84610328..b48a0899 100644
--- a/stem/descriptor/certificate.py
+++ b/stem/descriptor/certificate.py
@@ -242,15 +242,15 @@ class Ed25519Certificate(object):
<https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail>`_, for more
information see `RFC 7468 <https://tools.ietf.org/html/rfc7468>`_
- :returns: **bytes** for our encoded certificate representation
+ :returns: **unicode** for our encoded certificate representation
"""
- encoded = '\n'.join(stem.util.str_tools._split_by_length(base64.b64encode(self.pack()), 64))
+ encoded = b'\n'.join(stem.util.str_tools._split_by_length(base64.b64encode(self.pack()), 64))
if pem:
- return '-----BEGIN ED25519 CERT-----\n%s\n-----END ED25519 CERT-----' % encoded
- else:
- return encoded
+ encoded = b'-----BEGIN ED25519 CERT-----\n%s\n-----END ED25519 CERT-----' % encoded
+
+ return stem.util.str_tools._to_unicode(encoded)
@staticmethod
def _from_descriptor(keyword, attribute):
@@ -307,7 +307,7 @@ class Ed25519CertificateV1(Ed25519Certificate):
encoded = bytearray()
encoded += Size.CHAR.pack(self.version)
encoded += Size.CHAR.pack(self.type_int)
- encoded += Size.LONG.pack(stem.util.datetime_to_unix(self.expiration) / 3600)
+ encoded += Size.LONG.pack(int(stem.util.datetime_to_unix(self.expiration) / 3600))
encoded += Size.CHAR.pack(self.key_type)
encoded += self.key
encoded += Size.CHAR.pack(len(self.extensions))
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits