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.
# dictionary with key as alphabets value as numbers pairs
d = {
'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9,
'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18,
't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25
}
list1 = [] # initilaize an empty list
with open('filetext.txt', 'r') as f: # read file
for i in f.readlines(): # for each line in file append it to the list1
for j in i.splitlines():
list1.append(j)
n = int(input('Enter the value for shift key ')) # enter any number as shift key both sender and receiver should compromise on this key
for line in list1: # for each line in list1 convert it to lower case letters
str2 = ''
for i in line.lower():
if i == ' ' or i == '!' or i == '@' or i == '#' or i == '$' or i == '%' or i == '&' or i == '*' or i == '^': # if i is any punctuation then append as is
str2 += i
else:
jk = (d[i] + n) % 26 # else find the value for the letter
for k, j in d.items(): # compare the value with the dict value
if j == jk: # if both matches then get the key and append it to the str2
str2 += k
print("The encrypted value for the word ", line.lower(), ' is ', str2, '\n')


filetext.txt file

Write a Python program that reads text from a file, encrypts it with a Caesar Cipher,...
Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. Your program should: 1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8). 2. Change each character of the string by adding 6 to it. 3. Write the...
C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...
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...
Lab #10 C++ Write a C++ program that reads text from a file and encrypts the file by adding an encryption factor (EF) to the ASCII value of each character. The encryption factor is 1 for the first line and increases by 1 for each line up to 4 and then starts over at 1. So, for the 4 th line the EF is 4, for the 5th line it is 1, for the 10th line it is 2. In...
In Python, write a program that reads a text file that is provided by the user - ensure that the file exists before processing it! The file might be in a different directory, so be sure to test you logic - the user will provide the absolute path to the file if it is not in the same directory as the Python script! You should then ask the user for what string to search for in the file. Your program...
Create a C program: A caesar cipher is a simple cipher that shifts letters in a string. For example, shifting “ab” over by 1 would result in “bc”, and shifting “xyz” over by 2 would result in “zab”. The caesar program should take, in the command line an integer k, the amount to shift some text by, and a string f i l e, the name of a file containing text to encode using the cipher. For example, suppose “secret.txt”...
Assignment 7: Caesar Cipher Assignment 7 You will create a Caesar cipher which allows the user to specify the key and the text to be encrypted. A Caesar cipher is a simple substitution cipher wherein each letter in the message is shifted a certain number of spaces down the alphabet -- this number is called the key. a b c d e f g h i j k l m n o p q r s t u v w...
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...
In Python, do a basic encryption of a text file in the following
manner. The program encrypt.py will read in the following text file
and rearrange the lines in the file randomly and save the
rearranged lines of txt to another file called encrypted.txt. It
will also save another file called key.txt that will contain the
index of the lines that were rearranged in the encrypted file, so
for example if the 4th line from the original file is now...
Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is to create a program to encode files and strings using the caesar cipher encoding method. Information about the caesar method can be found at http://www.braingle.com/brainteasers/codes/caesar.php. Note: the standard caesar cipher uses an offset of 3. We are going to use a user supplied string to calculate an offset. See below for details on how to calculate this offset from this string. First open caesar.cpp...