aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-22 12:57:24 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-22 12:57:24 -0700
commit69d87e5326dd8a98e39be5c6bb2343983eeb3429 (patch)
tree5c0a8acf4cb118332fe3a9f231bdcdae263e08ed
parent9949702886c815277bb7483b1a0d429a2a7ffd7c (diff)
parent0b2042b6269bae9869a6ecbde586cec8158f4553 (diff)
downloadcryptography-69d87e5326dd8a98e39be5c6bb2343983eeb3429.tar.gz
cryptography-69d87e5326dd8a98e39be5c6bb2343983eeb3429.tar.bz2
cryptography-69d87e5326dd8a98e39be5c6bb2343983eeb3429.zip
Merge pull request #163 from reaperhulk/fix-bug-148
Return proper string type from hexdigest in py2/3
-rw-r--r--cryptography/primitives/hashes.py2
-rw-r--r--tests/primitives/test_hashes.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py
index c4bd8ad0..7133a916 100644
--- a/cryptography/primitives/hashes.py
+++ b/cryptography/primitives/hashes.py
@@ -44,7 +44,7 @@ class BaseHash(six.with_metaclass(abc.ABCMeta)):
self.digest_size)
def hexdigest(self):
- return binascii.hexlify(self.digest()).decode("ascii")
+ return str(binascii.hexlify(self.digest()).decode("ascii"))
def _copy_ctx(self):
return self._api.copy_hash_context(self._ctx)
diff --git a/tests/primitives/test_hashes.py b/tests/primitives/test_hashes.py
index 805d992b..03de8916 100644
--- a/tests/primitives/test_hashes.py
+++ b/tests/primitives/test_hashes.py
@@ -28,6 +28,10 @@ class TestBaseHash(object):
with pytest.raises(TypeError):
m.update(six.u("\u00FC"))
+ def test_base_hash_hexdigest_string_type(self, api):
+ m = hashes.SHA1(api=api, data=b"")
+ assert isinstance(m.hexdigest(), str)
+
class TestSHA1(object):
test_SHA1 = generate_base_hash_test(