msg = input("Enter Message: ")
key = input("Enter Key: ")
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
list2 = list(msg)
l1 = []
l2 = list(key)
l3=[]
for i in range(len(list2)):
for k in range(len(list1)):
if(l2[i%(len(l2))]==list1[k]):
key1=k
break
for j in range(len(list1)):
if (list2[i] == list1[j]):
CT = (j + key1) % 26
l1.append(list1[CT])
str = ''.join(l1)
print("Encrypted Message: "+str)
for i in range(len(str)):
for k in range(len(list1)):
if(l2[i%(len(l2))]==list1[k]):
key1=k
break
for j in range(len(list1)):
if (str[i] == list1[j]):
PT = (j - key1) % 26
l3.append(list1[PT])
dec = ''.join(l3)
print("Decrypted Message: " + dec)
key = input("Enter Key: ")
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
list2 = list(msg)
l1 = []
l2 = list(key)
l3=[]
for i in range(len(list2)):
for k in range(len(list1)):
if(l2[i%(len(l2))]==list1[k]):
key1=k
break
for j in range(len(list1)):
if (list2[i] == list1[j]):
CT = (j + key1) % 26
l1.append(list1[CT])
str = ''.join(l1)
print("Encrypted Message: "+str)
for i in range(len(str)):
for k in range(len(list1)):
if(l2[i%(len(l2))]==list1[k]):
key1=k
break
for j in range(len(list1)):
if (str[i] == list1[j]):
PT = (j - key1) % 26
l3.append(list1[PT])
dec = ''.join(l3)
print("Decrypted Message: " + dec)
Screenshot:
No comments:
Post a Comment