aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography/primitives/hashes.py
diff options
context:
space:
mode:
Diffstat (limited to 'cryptography/primitives/hashes.py')
-rw-r--r--cryptography/primitives/hashes.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py
index 06d90a90..e8c1f929 100644
--- a/cryptography/primitives/hashes.py
+++ b/cryptography/primitives/hashes.py
@@ -13,20 +13,24 @@
from __future__ import absolute_import, division, print_function
+import abc
+
import binascii
+import six
+
from cryptography.bindings import _default_api
-class BaseHash(object):
+class BaseHash(six.with_metaclass(abc.ABCMeta)):
def __init__(self, api=None, ctx=None):
if api is None:
api = _default_api
self._api = api
self._ctx = self._api.create_hash_context(self) if ctx is None else ctx
- def update(self, string):
- self._api.update_hash_context(self._ctx, string)
+ def update(self, data):
+ self._api.update_hash_context(self._ctx, data)
def copy(self):
return self.__class__(ctx=self._copy_ctx())
@@ -82,3 +86,9 @@ class Whirlpool(BaseHash):
name = "whirlpool"
digest_size = 64
block_size = 64
+
+
+class MD5(BaseHash):
+ name = "md5"
+ digest_size = 16
+ block_size = 64