Skip to content

Commit

Permalink
Make associated_data optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayrx committed Dec 13, 2014
1 parent 1f4fb2f commit 7c0cd82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aead/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, key, backend=default_backend()):
def generate_key(cls):
return base64.urlsafe_b64encode(os.urandom(32))

def encrypt(self, data, associated_data):
def encrypt(self, data, associated_data=b""):
iv = os.urandom(16)
return base64.urlsafe_b64encode(
self._encrypt_from_parts(data, associated_data, iv)
Expand All @@ -55,7 +55,7 @@ def _encrypt_from_parts(self, data, associated_data, iv):

return cipher_text + mac[:16]

def decrypt(self, data, associated_data):
def decrypt(self, data, associated_data=b""):
decoded_data = base64.urlsafe_b64decode(data)
mac = decoded_data[-16:]
iv = decoded_data[0:16]
Expand Down

0 comments on commit 7c0cd82

Please sign in to comment.