COMP4337 Lab1 Report
COMP4337 Lab1 Report
COMP4337 Lab1 Report
z5270429
Code
tempdes.py
iv = bytes.fromhex(sys.argv[1])
key = bytes.fromhex(sys.argv[2])
inputfiledir = sys.argv[3]
outputfiledir = sys.argv[4]
print('=' * 100)
print('Key used: ', [x for x in key])
tempaes.py
iv = Random.get_random_bytes(16)
key = Random.get_random_bytes(16)
inputfiledir = sys.argv[1]
outputfiledir = sys.argv[2]
print('=' * 100)
print('Key used: ', [x for x in key])
if remainder > 0:
length = 16 - remainder
padded_text += b'\x00' * length
start_time = time.time()
original_msg = aes2.decrypt(cipher_text)
decryption_time = time.time() - start_time
temprsa.py
import Crypto
from Crypto.PublicKey import RSA
from Crypto import Random
import ast
import sys
import time
inputfiledir = sys.argv[1]
timefiledir = sys.argv[2]
random_generator = Random.new().read
key = RSA.generate(1024, random_generator)
publickey = key.publickey()
print('=' * 100)
input = open(inputfiledir,"r")
plain_text = input.read()
encrypt_start = time.time()
cipher_text = publickey.encrypt(plain_text, 32)
encrypt_end = time.time()
decrypt_start = time.time()
decrypted = key.decrypt(ast.literal_eval(str(cipher_text)))
decrypt_end = time.time()
Graphs
Encryption
Decryption
AES Encryption and Decryption Times
Encryption
Decryption
RSA Encryption and Decryption Times
Encryption
Decryption
SHA-1 Digest Times
Questions
1) DES takes longer times than AES for encrypting and decrypting. From the
times we see that AES is almost 4x faster than DES when encrypting
2047152 bytes. When decrypting AES is almost 7x faster than DES.
2) DES is faster and takes shorter times than RSA. DES is approximately 2x
faster than RSA.
4) ?
5) RSA encryption is faster than decryption. The secret key while encrypting
using RSA is acquired by using an algorithm on the public key.