In: Computer Science
Cryptography and Applications
1. Write Python program to implement Caesar’s Cipher. Take user input to get plain text and key.
2. Write a Python program to implement Vignere Cipher. Take user input to get plain text and key.
TRY TO MAKE IT AS EASY AS YOU CAN.
1.
'''
"program to implement ceasar's cipher"
def encrypt(string, shiftkey):
cipher = ''
for char in string:
if char == ' ':
cipher = cipher + char
elif char.isupper():
cipher = cipher + chr((ord(char) + shiftkey - 65) % 26 + 65)
#Encrypt uppercase characters in plain text
else:
cipher = cipher + chr((ord(char) + shiftkey - 97) % 26 + 97)
#Encrypt lowercase characters in plain text
return cipher
print("program to implement ceasar's cipher")
text = input("enter string: ")
skey = int(input("enter shift number: ")) #number used to shift
character
print("original string: ", text)
print("after encryption: ", encrypt(text, skey)) # function call
inside print statement"
output:
program to implement ceasar's cipher
enter string: welcome to programming
enter shift number: 3
original string: welcome to programming
after encryption: zhofrph wr surjudpplqj
"Explanation for ceasar' cipher: