Menu

[solved]-Use Python 1 Type Run Following Program 2 Given Encrypted Sentence Clguba Vf Terng Using S Q39052210

use pythonThe Caesar Cipher The key for the Caesar Cipher will be a number from 1 to 26. Unless you know the key (that is know the numb

1) Type and run the following program:

# write a loop to show the original Alphabet alphabet = ! for i in range (65, 91, 1): alphabet += chr(i) print (alphabet =

2) You are given theencrypted sentence: CLGUBA VF TERNG

Using a Shiftof 13, what is the original (decyphered) message?

The Caesar Cipher The key for the Caesar Cipher will be a number from 1 to 26. Unless you know the key (that is know the number used to encrypt the message), you won’t be able to decrypt the secret code. The Caesar Cipher was one of the earliest ciphers ever invented. In this cipher, you encrypt a message by taking each letter in the message in cryptography, these letters are called symbols because they can be letters, numbers, or any other sign and replacing it with a “shifted” letter. If you shift the letter A by one space, you get the letter B. If you shift the letter A by two spaces, you get the letter C. Figure 14-1 is a picture of some letters shifted over by three spaces. ZAB ÇDEF – A|B|C|VĚDĚT GAM Figure 14-1: Shifting over letters by three spaces. Here, B becomes E. To get each shifted letter, draw out a row of boxes with each letter of the alphabet. Then draw a second row of boxes under it, but start a certain number this number is the key) of spaces over. After the letters at the end, wrap around back to the start of the boxes. Here is an example with the letters shifted by three spaces: ABCDEFGHIJKLMNOPQRSTUVWXYZ DEFGHIJKLMNOPQRSTUVWXYZ ABC Alphabet shifted by 3 spaces. # write a loop to show the original Alphabet alphabet = “! for i in range (65, 91, 1): alphabet += chr(i) print (‘alphabet = ‘, alphabet) shift = 3 # show the shift ‘key’ print(‘shift =’, shift, ‘letters’) # Write a loop to show alphabet shifted by 3 : encrypted = !! for i in range (65, 91, 1): if i + shift < 91: encrypted += chr(i+shift) if i + shift >= 91: encrypted += chr(65 +(i+shift-91)) # show encrypted alphabet print(‘encrypted =’, encrypted) encrypt = { } # make an empty dictionary decypher = { } encrypt [”] = ”# add to dictionary decypher [!!] = !! ^^ KEY ^^^VALUE ASSOCIATED WITH KEY for i in range (0, len (alphabet), 1): encrypt [ alphabet[i] ] = encrypted [i] decypher [ encrypted [i] ] = alphabet [ i] original_message = “HELLO WORLD” encrypted message = “! for i in range (0, len (original_message), 1): if original message[i] == ”: encrypted message += !! else: encrypted_message += encrypt [ original_message [i] ] print(‘original sentence:’, original_message) # HELLO WORLD print(‘encrypt. sentence:’, encrypted message) print(” … decyphered : ‘, end=”) for i in range (0, len (encrypted message), 1): print ( decypher (encrypted message[i] ] , end=”) Show transcribed image text The Caesar Cipher The key for the Caesar Cipher will be a number from 1 to 26. Unless you know the key (that is know the number used to encrypt the message), you won’t be able to decrypt the secret code. The Caesar Cipher was one of the earliest ciphers ever invented. In this cipher, you encrypt a message by taking each letter in the message in cryptography, these letters are called symbols because they can be letters, numbers, or any other sign and replacing it with a “shifted” letter. If you shift the letter A by one space, you get the letter B. If you shift the letter A by two spaces, you get the letter C. Figure 14-1 is a picture of some letters shifted over by three spaces. ZAB ÇDEF – A|B|C|VĚDĚT GAM Figure 14-1: Shifting over letters by three spaces. Here, B becomes E. To get each shifted letter, draw out a row of boxes with each letter of the alphabet. Then draw a second row of boxes under it, but start a certain number this number is the key) of spaces over. After the letters at the end, wrap around back to the start of the boxes. Here is an example with the letters shifted by three spaces: ABCDEFGHIJKLMNOPQRSTUVWXYZ DEFGHIJKLMNOPQRSTUVWXYZ ABC Alphabet shifted by 3 spaces.
# write a loop to show the original Alphabet alphabet = “! for i in range (65, 91, 1): alphabet += chr(i) print (‘alphabet = ‘, alphabet) shift = 3 # show the shift ‘key’ print(‘shift =’, shift, ‘letters’) # Write a loop to show alphabet shifted by 3 : encrypted = !! for i in range (65, 91, 1): if i + shift = 91: encrypted += chr(65 +(i+shift-91)) # show encrypted alphabet print(‘encrypted =’, encrypted) encrypt = { } # make an empty dictionary decypher = { } encrypt [”] = ”# add to dictionary decypher [!!] = !! ^^ KEY ^^^VALUE ASSOCIATED WITH KEY for i in range (0, len (alphabet), 1): encrypt [ alphabet[i] ] = encrypted [i] decypher [ encrypted [i] ] = alphabet [ i] original_message = “HELLO WORLD” encrypted message = “! for i in range (0, len (original_message), 1): if original message[i] == ”: encrypted message += !! else: encrypted_message += encrypt [ original_message [i] ] print(‘original sentence:’, original_message) # HELLO WORLD print(‘encrypt. sentence:’, encrypted message) print(” … decyphered : ‘, end=”) for i in range (0, len (encrypted message), 1): print ( decypher (encrypted message[i] ] , end=”)

Expert Answer


Answer to use python 1) Type and run the following program: 2) You are given the encrypted sentence: CLGUBA VF TERNG Using a Shift… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *