From fa7081a6275b876c0fd734d0ac3a27b591b661f6 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 1 Nov 2013 16:38:25 -0700 Subject: Update for new API --- cryptography/fernet.py | 8 ++++---- 1 file 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 -- cgit v1.2.3