Skip to content

Instantly share code, notes, and snippets.

@jlaine
Last active June 5, 2019 11:58
Show Gist options
  • Save jlaine/8f41eec1fc5280e687a7eaa7004e0b29 to your computer and use it in GitHub Desktop.
Save jlaine/8f41eec1fc5280e687a7eaa7004e0b29 to your computer and use it in GitHub Desktop.
import time
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
# typical values for QUIC using AES-256-GCM
key = bytes(32)
nonce = bytes(12)
data = bytes(1200)
additional_data = bytes(20)
aead = AESGCM(key)
# encryption
start = time.time()
for _ in range(1000000):
aead.encrypt(nonce, data, additional_data)
print("encryption", time.time() - start)
# decryption
encrypted = aead.encrypt(nonce, data, additional_data)
start = time.time()
for _ in range(1000000):
aead.decrypt(nonce, encrypted, additional_data)
print("decryption", time.time() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment