Skip to content
Permalink
1ca5769fb9
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
28 lines (20 sloc) 835 Bytes
#!/usr/bin/env python3
import time
from Crypto.Cipher import Blowfish
from Crypto.Util.Padding import pad
# define key and IV
key = b'KEYKEYKE'
iv = b'IVIVIVIV'
# define data sizes to test
size_handling = [100000, 500000, 1000000 ,5000000,10000000]
# iterate over data sizes and test encryption time and data handling
for i in size_handling:
message = b'Which witch switched the Swiss wristwatches?' * i
start_time = time.time()
# create cipher object with Blowfish algorithm in CBC mode
cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)
padding = pad(message, Blowfish.block_size) #additional padding
ciphertext = cipher.encrypt(padding)# encrypting data
end_time = time.time()
total_time = end_time - start_time
print(f"Encryption time: {total_time} seconds for encrypted bytes: {i}")