You are on page 1of 2

def machine():

print("Welcome to symetric cryptography machine based on Caesar's cypher


algorithm")
# creating key strings
keys = 'abcdefghijklmnopqrstuvwxyz !'
# auto generating the vaules of strings
# value will be generted by taking last to first
# concatinated with the rest of the string
values = keys[-1] + keys[0:-1]
# print(keys)
# print(values)
# creating two dictionaries
encrytDict = dict(zip(keys, values))
decryptDict = dict(zip(values, keys))

# user input
message = input("Enter your secret message: ")
mode = input("Crypto Mode : Encode(E) OR Decode(D)")
#encode and decode
if mode.upper() == 'E':
newMessage = ''.join([encrytDict[letter]
for letter in message.lower()])
elif mode.upper() == 'D':
newMessage = ''.join([decryptDict[letter]
for letter in message.lower()])
else:
print("Please try again, wrong choice entered")

return newMessage.capitalize()

def reverse() :
print("Welcome to Reverse Cipher Algorithm ")
message = input("Please enter your secret message ")
translated = '' #cipher text is stored in this variable
i = len(message) - 1
while i >= 0:
translated = translated + message[i]
i = i - 1
print("The cipher text is : " , translated)

print("Hi! ")
i=1
n=" "

while i!=0 or i!="exit" or i!="Exit":


print("enter r for reverse and c for ceaser cipher algorithm")
n=input()
if n=="r":
print(reverse())
elif n=="c":
print(machine())
print("This Minor project is made by Jatin Sood & Manjot Singh")
i=input("enter zero(0) if want to exit or type exit and any key except these keys
for continue")

You might also like