Skip to content
Permalink
main
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
#!/usr/bin/env python3
from Crypto.Cipher import DES3
from Crypto.Util.Padding import pad
import os
import time
# generation of keys and iv
key = b'TWENTYFOURBYTEKEY3DES$$$'
iv = b'IVIVIVIV'
# Create a 3DES cipher object with the key and IV
cipher = DES3.new(key, DES3.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
t1 = time.time()
padding = pad(message, DES3.block_size) #additional padding
ciphertext = cipher.encrypt(message) # encrypts secret message
t2 = time.time()
total_time = t2 - t1 # total time taken to encrypt
print(f"time taken for secret message * {i} encryption bytes: {total_time} seconds")