Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Dissertation_sourcecode/AES-128.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (17 sloc)
713 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from Crypto.Cipher import AES | |
import os | |
import time | |
key = os.urandom(16) | |
iv = os.urandom(16) | |
# Create an AES-128 cipher object with the key and IV | |
cipher = AES.new(key, AES.MODE_CBC, iv) | |
size_handling = [100000,500000,1000000,5000000,10000000] | |
# Measure the time taken to encrypt messages of increasing size | |
for i in size_handling: | |
message = b'Which witch switched the Swiss wristwatches?' * i | |
initial_time = time.time() | |
ciphertext = cipher.encrypt(message) #encrypts secret message | |
end_time = time.time() | |
total_time = end_time - initial_time #total time taken to encrypt | |
print(f"time taken for secret message * {i} encryption bytes: {total_time} seconds") | |