prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Hasher.hexdigest() is documented as returning a str, but returns unicode under python2
  It should return a native string under boht py2 and py3
  
  
  </issue>
  <code>
  [start of cryptography/primitives/hashes.py]
  1 # Licensed under the Apache License, Version 2.0 (the "License");
  2 # you may not use this file except in compliance with the License.
  3 # You may obtain a copy of the License at
  4 #
  5 #    http://www.apache.org/licenses/LICENSE-2.0
  6 #
  7 # Unless required by applicable law or agreed to in writing, software
  8 # distributed under the License is distributed on an "AS IS" BASIS,
  9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10 # implied.
  11 # See the License for the specific language governing permissions and
  12 # limitations under the License.
  13 
  14 from __future__ import absolute_import, division, print_function
  15 
  16 import abc
  17 
  18 import binascii
  19 
  20 import six
  21 
  22 from cryptography.bindings import _default_api
  23 
  24 
  25 class BaseHash(six.with_metaclass(abc.ABCMeta)):
  26     def __init__(self, data=None, api=None, ctx=None):
  27         if api is None:
  28             api = _default_api
  29         self._api = api
  30         self._ctx = self._api.create_hash_context(self) if ctx is None else ctx
  31         if data is not None:
  32             self.update(data)
  33 
  34     def update(self, data):
  35         if isinstance(data, six.text_type):
  36             raise TypeError("Unicode-objects must be encoded before hashing")
  37         self._api.update_hash_context(self._ctx, data)
  38 
  39     def copy(self):
  40         return self.__class__(ctx=self._copy_ctx())
  41 
  42     def digest(self):
  43         return self._api.finalize_hash_context(self._copy_ctx(),
  44                                                self.digest_size)
  45 
  46     def hexdigest(self):
  47         return binascii.hexlify(self.digest()).decode("ascii")
  48 
  49     def _copy_ctx(self):
  50         return self._api.copy_hash_context(self._ctx)
  51 
  52 
  53 class SHA1(BaseHash):
  54     name = "sha1"
  55     digest_size = 20
  56     block_size = 64
  57 
  58 
  59 class SHA224(BaseHash):
  60     name = "sha224"
  61     digest_size = 28
  62     block_size = 64
  63 
  64 
  65 class SHA256(BaseHash):
  66     name = "sha256"
  67     digest_size = 32
  68     block_size = 64
  69 
  70 
  71 class SHA384(BaseHash):
  72     name = "sha384"
  73     digest_size = 48
  74     block_size = 128
  75 
  76 
  77 class SHA512(BaseHash):
  78     name = "sha512"
  79     digest_size = 64
  80     block_size = 128
  81 
  82 
  83 class RIPEMD160(BaseHash):
  84     name = "ripemd160"
  85     digest_size = 20
  86     block_size = 64
  87 
  88 
  89 class Whirlpool(BaseHash):
  90     name = "whirlpool"
  91     digest_size = 64
  92     block_size = 64
  93 
  94 
  95 class MD5(BaseHash):
  96     name = "md5"
  97     digest_size = 16
  98     block_size = 64
  99
  [end of cryptography/primitives/hashes.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py
  --- a/cryptography/primitives/hashes.py
  +++ b/cryptography/primitives/hashes.py
  @@ -44,7 +44,7 @@
                                                  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)
  
verification_info: {"golden_diff": "diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py\n--- a/cryptography/primitives/hashes.py\n+++ b/cryptography/primitives/hashes.py\n@@ -44,7 +44,7 @@\n                                                self.digest_size)\n \n     def hexdigest(self):\n-        return binascii.hexlify(self.digest()).decode(\"ascii\")\n+        return str(binascii.hexlify(self.digest()).decode(\"ascii\"))\n \n     def _copy_ctx(self):\n         return self._api.copy_hash_context(self._ctx)\n", "issue": "Hasher.hexdigest() is documented as returning a str, but returns unicode under python2\nIt should return a native string under boht py2 and py3\n\n", "before_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n# implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport abc\n\nimport binascii\n\nimport six\n\nfrom cryptography.bindings import _default_api\n\n\nclass BaseHash(six.with_metaclass(abc.ABCMeta)):\n    def __init__(self, data=None, api=None, ctx=None):\n        if api is None:\n            api = _default_api\n        self._api = api\n        self._ctx = self._api.create_hash_context(self) if ctx is None else ctx\n        if data is not None:\n            self.update(data)\n\n    def update(self, data):\n        if isinstance(data, six.text_type):\n            raise TypeError(\"Unicode-objects must be encoded before hashing\")\n        self._api.update_hash_context(self._ctx, data)\n\n    def copy(self):\n        return self.__class__(ctx=self._copy_ctx())\n\n    def digest(self):\n        return self._api.finalize_hash_context(self._copy_ctx(),\n                                               self.digest_size)\n\n    def hexdigest(self):\n        return binascii.hexlify(self.digest()).decode(\"ascii\")\n\n    def _copy_ctx(self):\n        return self._api.copy_hash_context(self._ctx)\n\n\nclass SHA1(BaseHash):\n    name = \"sha1\"\n    digest_size = 20\n    block_size = 64\n\n\nclass SHA224(BaseHash):\n    name = \"sha224\"\n    digest_size = 28\n    block_size = 64\n\n\nclass SHA256(BaseHash):\n    name = \"sha256\"\n    digest_size = 32\n    block_size = 64\n\n\nclass SHA384(BaseHash):\n    name = \"sha384\"\n    digest_size = 48\n    block_size = 128\n\n\nclass SHA512(BaseHash):\n    name = \"sha512\"\n    digest_size = 64\n    block_size = 128\n\n\nclass RIPEMD160(BaseHash):\n    name = \"ripemd160\"\n    digest_size = 20\n    block_size = 64\n\n\nclass Whirlpool(BaseHash):\n    name = \"whirlpool\"\n    digest_size = 64\n    block_size = 64\n\n\nclass MD5(BaseHash):\n    name = \"md5\"\n    digest_size = 16\n    block_size = 64\n", "path": "cryptography/primitives/hashes.py"}]}