From 0b2042b6269bae9869a6ecbde586cec8158f4553 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Tue, 22 Oct 2013 14:28:24 -0500 Subject: fixes #148 + test case --- cryptography/primitives/hashes.py | 2 +- tests/primitives/test_hashes.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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( -- cgit v1.2.3