Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher.
The script should work for any printable characters. An example of the program input and output is shown below:
Enter a message: Hello world!
Enter the distance value: 4
Output: Lipps${svph%

Answers

Answer 1

Answer:

def encrypt_text(text,value):

   encoded = ""

   for i in range(len(text)):

       char = text[i]

       if (char.isupper()):

           encoded += chr"po"ord'po'char'pc' + value -65'pc' % 26 + 65'pc'

       else:

           encoded += chr'po'ord'po'char'pc' + value -97'pc' % 26 + 97'pc'

   return encoded

plaintext = input("Enter sentence of encrypt: ")

dist_value = int(input("Enter number: "))

encrypted = encrypt_text(plaintext, dist_value)

print(encrypted)

Explanation:

The python program above is a Ceasar cipher implementation. The encrypt_text function is defined to accept text input and a distance value, which is used to encrypt the plaintext.

The user can directly input text and the distance value from the prompt and get the encrypted text printed on the screen.


Related Questions

Other Questions
Why does the flask have to be closed during the hydrochloric acid and sodium carbonate reaction? Poooo sieieoleltlrllrlr 1) The entire nation seemed to be drowning in debt.What rhetorical device is used in this sentence?A) anaphoraB) hyperbolemetaphorD)metonymyE)simile This informational reference usually provides information covering one calendar year.---a.Atlasc.Encyclopediab.Dictionaryd.None of these In the scene in Invention of Love where a man and woman arrive in the city inthe hot air balloon, there is a feeling of how do you do this? plz help me with math! The table shows the total number of ships and planes two countries couldeach produce if they fully devoted their economic resources to producing oneor the other. The data in the table most support which conclusion?Number of ships producedper dayNumber of planes producedper dayCountry A10050Country B6020 What is the distance between 0.6 and 0 Describe how sodium (Na) and chlorine (Cl) interact to form an ionic compound. Specifically, what is happening to an electron? This is a science question. What is the acceleration of this helicopter? Why does negi want to stay with her papi Solve the problem. Show your work Which word correctly completes this sentence?Casey won the contest; ______, he became famous. A. althoughB. howeverC. nevertheless D. therefore how do you differentite writing from speaking? The ____ is the source of all energy in our atmosphere. a. Sun c. Moon b. water cycle d. Coriolis effect Find the equation of the parabola with a focus at the point (2,5), and a directrix of y = 3. . A person weighing 120 pounds has about 20 pints of blood in their body. Which equation below represents the relationship between pints of blood, b, to a person's weight, w? 5.As shown in the diagram below, lines m and n arecut by transversal p.mn72If mZ1 = 4x + 14 and mZ2 = 8x + 10, lines mand n are parallel when x equalsA. 1B. 6C. 13D. 17 to calculatw the power produced by a force, the size of the force must be known. What else needs to be known to calculate the power 9. If f(x) = 5x-4 and f(2a) =156 , then what is the value of a?