aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-21 21:42:00 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-21 21:42:00 -0700
commit7b3c1b96d0fb37aaedf93d226a16389b78612f8c (patch)
treee63609d0d2b75c0e26d5b8cac539bff5c53f79d6 /cryptography
parentf988a9ebc594bf1e5c996164befe69f1225dd564 (diff)
parente524d73d76d63c6399a55cd80cec53cf39c98659 (diff)
downloadcryptography-7b3c1b96d0fb37aaedf93d226a16389b78612f8c.tar.gz
cryptography-7b3c1b96d0fb37aaedf93d226a16389b78612f8c.tar.bz2
cryptography-7b3c1b96d0fb37aaedf93d226a16389b78612f8c.zip
Merge branch 'master' into triple-des
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/primitives/hashes.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py
index e8c1f929..c4bd8ad0 100644
--- a/cryptography/primitives/hashes.py
+++ b/cryptography/primitives/hashes.py
@@ -23,13 +23,17 @@ from cryptography.bindings import _default_api
class BaseHash(six.with_metaclass(abc.ABCMeta)):
- def __init__(self, api=None, ctx=None):
+ def __init__(self, data=None, 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
+ if data is not None:
+ self.update(data)
def update(self, data):
+ if isinstance(data, six.text_type):
+ raise TypeError("Unicode-objects must be encoded before hashing")
self._api.update_hash_context(self._ctx, data)
def copy(self):