diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-01 16:38:25 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-01 16:38:25 -0700 |
commit | fa7081a6275b876c0fd734d0ac3a27b591b661f6 (patch) | |
tree | b146a5037a92c7bb4b87520d09b9da00b36be2af | |
parent | eca9f36c66274928cc8d113ab114c55b2f05b621 (diff) | |
download | cryptography-fa7081a6275b876c0fd734d0ac3a27b591b661f6.tar.gz cryptography-fa7081a6275b876c0fd734d0ac3a27b591b661f6.tar.bz2 cryptography-fa7081a6275b876c0fd734d0ac3a27b591b661f6.zip |
Update for new API
-rw-r--r-- | cryptography/fernet.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cryptography/fernet.py b/cryptography/fernet.py index f9d5e93f..f907a363 100644 --- a/cryptography/fernet.py +++ b/cryptography/fernet.py @@ -64,12 +64,12 @@ class Fernet(object): ).encryptor() ciphertext = encryptor.update(padded_data) + encryptor.finalize() - h = HMAC(self.signing_key, digestmod=hashes.SHA256) + h = HMAC(self.signing_key, hashes.SHA256()) h.update(b"\x80") h.update(struct.pack(">Q", current_time)) h.update(iv) h.update(ciphertext) - hmac = h.digest() + hmac = h.finalize() return base64.urlsafe_b64encode( b"\x80" + struct.pack(">Q", current_time) + iv + ciphertext + hmac ) @@ -95,9 +95,9 @@ class Fernet(object): if ttl is not None: if struct.unpack(">Q", timestamp)[0] + ttl < current_time: raise InvalidToken - h = HMAC(self.signing_key, digestmod=hashes.SHA256) + h = HMAC(self.signing_key, hashes.SHA256()) h.update(data[:-32]) - hmac = h.digest() + hmac = h.finalize() if not lib.constant_time_compare(hmac, len(hmac), data[-32:], 32): raise InvalidToken |