Write a script in python 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.
NOTE: The code i have written will encrypt every printable
character including space, special symbol etc.
Code:
def main():
# fetching plaintext as input
line = input('Enter a plaintext: ')
# taking the distance value
dist = int(input('Enter the shift value: '))
enc_char = ''
# iterating through each character in line
for char in line:
# if char is an alphabet
if char.isalpha():
num = ord(char)
num += dist
# if char is a lowercase
if char.islower():
if num > ord('z'):
num -= 26
elif num < ord('a'):
num += 26
# if char is an uppercase
elif char.isupper():
if num > ord('Z'):
num -= 26
elif num < ord('A'):
num += 26
enc_char += chr(num)
# if char is not an alphabet and it is some digit or special character
else:
num = ord(char)
num += dist
# assuming ascii characters are upto 127 characters
# if the char crossed this 127 we will rotate it
if num > 127:
num -= 127
enc_char += chr(num)
print('The encrypted text is: ', enc_char)
if __name__=='__main__':
main()
Sample
Output:

Write a script in python that inputs a line of plaintext and a distance value and...
Write a script that inputs a line of encrypted text and a distance value and outputs plaintext using a Caesar cipher. The script should work for any printable characters. An example of the program input and output is shown below: Enter the coded text: Lipps${svph% Enter the distance value: 4 Hello world! # Request the inputs codedText = input("Enter the coded text: ") distanceValue = int(input("Enter the distance value: ")) # Calculate the decryption plainText = "" for cr in...
So I wrote 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: plainText = input("Enter a message: ") distance = int(input("Enter the distance value: ")) code = "" for ch in plainText: ordValue = ord(ch) cipherValue = ordValue + distance if cipherValue > 127: cipherValue = distance - (127 - ordValue + 1) code += chr(cipherValue) print(code) Now I need...
Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher.
Using Python; Caesar part of the homework: Write c_encrypt() and c_decrypt(), both of which take two arguments, the first one a string and the second one an integer key. Both should return a string. Vigenère part of the homework: Write vig_encrypt() and vig_decrypt() functions. Each takes two strings as inputs, with the first being the plaintext/ciphertext, and the second being the key. Both should be calling functions you wrote earlier to help make the work easier. The key will be...
Write a Python program which implements the following two classical cryptosystem which we covered n class: a) Affine Cipher b) Vigenere Cipher Your program should consist of at least five functions: a) Two functions named encrypt, one for each of the two algorithms which accepts a lowercase alphabetical plaintext string and key as input and outputs a corresponding cipher text string. b) Two functions named decrypt, one for each of the two algorithms which accepts a lowercase alphabetical ciphertext string...
Write a Python program that reads text from a file, encrypts it with a Caesar Cipher, and displays the encrypted text. Do not process punctuation. Convert the original string to all lower-case before encrypting it.
USING C LANGUAGE Write a program to compute a Caesar Cipher . You must read in a file of text and convert some of the letters to another letter using the following array: char key[27] = “efghijklmnopqrstuvwxyzabcd”; This means that if you encounter the letter ‘a’, then you will replace it with the letter ‘e’,etc. If you encounter any other characters in the input file (example: ‘A’ or space, etc, you will write them as is. You will write each...
Write the programming C please, not C++. The main function
should be to find the offset value of the ciper text
"wPL2KLK9PWWZ7K3ST24KZYKfPMKJ4SKLYOKRP4KFKP842LK0ZTY43 " and
decrypt it.
In cryptography, a Caesar Cipher is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be...
Python code. NO importing modules. you may not use: contains(), index(), sum(),join(), split(). def column_cipher(plaintext): • Parameter(s): plaintext ----- a string; the message to be encrypted • Return value: A string; the ciphertext after applying the column cipher algorithm • Assumptions: o The standard English alphabet is used: "abcdefghijklmnopqrstuvwxyz" o All strings will be non-empty, entirely lowercase, and only contain valid letters in the alphabet. • How it works: o First, transpose the text into 5 different columns by writing...
The given plaintext is “Feistel cipher structure uses the same algorithm for both encryption and decryption”. Write Java or Python code to implement Shift cipher(Encryption and Decryption) and test your code on given plaintext. Your code must meet following conditions. (5 points) User must enter the value of key from command prompt and print it at command prompt. (2.5 points) Print the cipher text and the plaintext at the command prompt after encryption and decryption. (2.5 points) Test your algorithm...