Question: Your first assignment is implementing autokey ( one time pad ) functionality to Vernam Cipher. Initial code is attached. You can use that code to
Your first assignment is implementing autokey one time pad functionality to Vernam Cipher.
Initial code is attached. You can use that code to implement.
You can use any programming language, but in this case you need to implement Vernam Cipher by yourself.i would like to use pyhton
The assignment is as below;
You need to have ten passwords and ten plain texts
each plain text will be ecrypted with a different password. After encryption, the cipher text will be decrypted by the same password
After encryption or decryption, throw away used password
make sure, in the code, by testing that, you decrypted text and plain text are the same
generate the password with diffie helman
do the encrption and decrytion on two different servers, witout sharing the password diffie hellman
Complete all the required tasks in the assignment using this code below
# Vernam Cipher
import random
#and
AND
A B R
OR
A B R
XOR
A B R
def generatekeyplaintextlength:
key joinrandomchoiceABCDEFGHIJKLMNOPQRSTUVWXYZ for in rangeplaintextlength
return key
def encryptplaintext key:
#a
# HELLO
# ASDF
# zip HELLO ASDF
# c c
# H A
# E S
#
#
# XOR:
#
ciphertext
for p k in zipplaintext key:
ciphertext strchrordp ordk
return ciphertext
def decryptciphertext key:
for c k in zipciphertext key:
decryptedtext strchrordc ordk
return decryptedtext
# Example usage
if namemain:
plaintext "HELLO"
key generatekeylenplaintext
printPlaintext: plaintext
printKey: key
ciphertext encryptplaintext key
printCiphertext: ciphertext
decryptedtext decryptciphertext key
printDecrypted Text:", decryptedtext
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
