updated readme and added some new prints to part 1 / 2
This commit is contained in:
1 parent
7baca9ed2f
commit
253a2f62ac
5 files changed
+36
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# About
|
||||
|
||||
This is the Cryptography homework 3.
|
||||
|
||||
# Usage
|
||||
|
||||
## Installation
|
||||
|
||||
Please install `pycryptodome` using Python 3.10.
|
||||
|
||||
## Part 1
|
||||
|
||||
First run `alice.py` and input the message.
|
||||
Run `bob.py` to decrypt the message.
|
||||
|
||||
## Part 2
|
||||
|
||||
Run `bob.py` to generate bob's public and private keys.
|
||||
Run `alice.py` and enter a message.
|
||||
Run `bob.py` to decrypt the message.
|
||||
|
||||
## Part 3
|
||||
|
||||
Run `speed-test.py` or speed-test-nokey.py`.
|
||||
|
||||
The difference between the two is that nokey doesn't generate a new key for each encryption and decryption.
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ cipher = AES.new(aes_key, AES.MODE_CBC, iv=b'0'*16)
|
||||
|
||||
ciphertext = cipher.encrypt(plaintext)
|
||||
|
||||
print(f'Ciphertext: {ciphertext}')
|
||||
|
||||
with open('ctext', 'wb') as f:
|
||||
f.write(ciphertext)
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ cipher = AES.new(aes_key, AES.MODE_CBC, iv=b'0'*16)
|
||||
with open('ctext', 'rb') as f:
|
||||
ciphertext = f.read()
|
||||
|
||||
print(f'Ciphertext: {ciphertext}')
|
||||
|
||||
plaintext = unpad(cipher.decrypt(ciphertext), 16).decode()
|
||||
|
||||
print(f'Plaintext: {plaintext}')
|
||||
|
||||
@@ -14,6 +14,8 @@ cipher = PKCS1_OAEP.new(public_key)
|
||||
# Encrypt the message
|
||||
ciphertext = cipher.encrypt(message)
|
||||
|
||||
print(f'Ciphertext: {ciphertext}')
|
||||
|
||||
# Write the ciphertext
|
||||
with open("ctext", "wb") as f:
|
||||
f.write(ciphertext)
|
||||
|
||||
@@ -31,6 +31,8 @@ with open("bob_private.pem", "rb") as f:
|
||||
with open("ctext", "rb") as f:
|
||||
ciphertext = f.read()
|
||||
|
||||
print(f'Ciphertext: {ciphertext}')
|
||||
|
||||
cipher = PKCS1_OAEP.new(private_key)
|
||||
|
||||
# Decrypt
|
||||
|
||||
Reference in new issue
Block a user