Write a program that encrypts and decrypts the user input
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Write a program that encrypts and decrypts the user input

Question 5

Write a 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 word that will be used for encryption/decryption.  Each character of the user’s input should be offset by the value of the same character in your secret word.  For example, if my secret word is “cab” and the user wants to encrypt “apples”.
c a b c a b
3 1 2 3 1 2
   
a p p l e s
1 16 16 12 5 19
   
4 17 18 15 6 21
d q r o f u

The encrypted output would be “dqrofu”.
The program should ask the user for input to encrypt, and then display the resulting encrypted output.  Next your program should ask the user for input to decrypt, and then display the resulting decrypted output.
Enter phrase to Encrypt (lowercase, no spaces):  apples
Result: dqrofu

Enter phrase to Decrypt (lowercase, no spaces):  dqrofu
Result: apples

Hint
Management Code#the secret key to usesecretKey='cab'#get plain text to be encyptedplainText=input('enter phrase to Encrypt (lowercase, no space): ')encryptedText=''#holds index of the current character in plain text being encryptedcurrIndex=-1for strChar in plainText: currIndex=currIndex+1 #index of the character to use for encryption secretKeyIndex=currIndex%len(secretKey) #ascii number ...

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.