diff options
author | Donald Stufft <donald@stufft.io> | 2013-10-19 20:59:12 -0700 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-10-19 20:59:12 -0700 |
commit | 7abcb9c0e87787d58f4754c079a3296aaedae657 (patch) | |
tree | cef8d5454e951721ed92cd71c5e0b23c7ebc0551 /cryptography | |
parent | 1caf8ab5ec72d8373bc9af7a9f7b63c2ac0826f7 (diff) | |
parent | 746815b8f2b6a485b41e37c67969ed21338946db (diff) | |
download | cryptography-7abcb9c0e87787d58f4754c079a3296aaedae657.tar.gz cryptography-7abcb9c0e87787d58f4754c079a3296aaedae657.tar.bz2 cryptography-7abcb9c0e87787d58f4754c079a3296aaedae657.zip |
Merge pull request #130 from reaperhulk/hash-saga-thrilling-conclusion-md5
Hash Saga Part 7 (MD5 support + docs)
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/primitives/hashes.py | 16 |
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 |