Question

In: Computer Science

Cryptography and Applications 1. Write Python program to implement Caesar’s Cipher. Take user input to get...

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.

Solutions

Expert Solution

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:

  • In Caesar Cipher each letter of plain text is replaced by a letter with some fixed number of positions down with alphabet. We need to pass the text to be encrypted using Caesar cipher along with the shift key length (fixed difference) then to encrypt our data; we have to replace each letter in the text by some other letter at a fixed difference.
  • If we give key length as “2” then letter “t” will be changed to “v”, “h” will be changed to “j” and so on."
  • In our program have used text as welcome to programming  “ which encrypted as “zhofrph wr surjudpplqj “

Related Solutions

Cryptography and Applications 1. Write Python program to implement Caesar’s Cipher. Take user input to get...
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.
Write a Python program to implement Vignere Cipher. Take user input to get plain text and...
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.
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input...
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x)...
Step by step in python Write a program that will keep asking for a user input...
Step by step in python Write a program that will keep asking for a user input (until a blank line is entered) and will inform me whether what I entered was a valid number or not (without crashing). The program should use at least one try/except loop The program should include at least two custom written functions (a main() function can count as one of the two)
write a progam in python that willl take user input for item and price and save...
write a progam in python that willl take user input for item and price and save them in a dictionary. Then print the item and price and the total price.
Python Program Write a program that will ask a user on how many input colored balls...
Python Program Write a program that will ask a user on how many input colored balls of the following codes: R-red, B-blue, W-white, G-green and O-orange -will he or she would like to enter in the program and print the total number of Red balls were encountered. Assume an uppercase and lower case letter will be accepted.
PYTHON Write a program that accepts a range of input from the user and checks whether...
PYTHON Write a program that accepts a range of input from the user and checks whether the input data is sorted or not. If the data series is already sorted your program should print “True” or should print “False” otherwise. You should not use any sort function for this program. Input: How many numbers you want to input: 3 # user input 3 Input the number: 5 Input the number: 2 Input the number: 7 Output: False
Write a Python program which prompts the user to input a string. Then, print the string...
Write a Python program which prompts the user to input a string. Then, print the string in reverse to the terminal Sample output Please enter a word: "zeus" The reverse of zeus is suez Hint: There are several ways to accomplish this. Recall that a string is an itterable object and therefore can be used with a for loop
Need this program in python. The data must be taken from user as input. Write a...
Need this program in python. The data must be taken from user as input. Write a program that prompts the user to select either Miles-to-Kilometers or Kilometers-to-Miles, then asks the user to enter the distance they wish to convert. The conversion formula is: Miles = Kilometers X 0.6214 Kilometers = Miles / 0.6214 Write two functions that each accept a distance as an argument, one that converts from Miles-to-Kilometers and another that converts from Kilometers-to-Miles The conversion MUST be done...
Write a program in C++ to implement Lamport’s logical clocks. Your program should take as input...
Write a program in C++ to implement Lamport’s logical clocks. Your program should take as input a description of several process schedules (i.e., lists of send, receive or print operations). The output of your program will be a linearization of these events in the order actually performed, annotated with Lamport clock values. The input of the program will be a collection of processes, each with a list of operations to perform. The processes are named p1...pn for some n (you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT