Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this programming assignment, the goal is to write several functions related t

ID: 3732749 • Letter: I

Question

In this programming assignment, the goal is to write several functions related to the implemen- tation of a Caesar cipher. Wikipedia: It is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. Toward the implementation of concepts of Caesar cipher, you are asked to do the following tasks: Write a function named caesar encrypt (textfile,shift paraneter) that takes as pa- rameters the name of a text file to be encrypted and a positive shift parameter, and return a string that is the caesar-encrypted version of the text file . Write a function write.to file(aString, sone text file) that takes a string as pa- rameter and write it to the file with the name given by the second parameter Write a function named caesar decrypt (encrypted textfile,shift paraneter) that takes as parameters the name of an encrypted text file and the known shift parameter, and return a string that is the caesar-encrypted version of the text file e Write a function named infer shift (encrypted textfile, language) that takes as pa- rameters the name of an encrypted text file and the language in the text, and return a positive that is the shift that was used to encrypt the text file. The default parameter for the language is english. . Write a function named caesar decrypt2(encrypted.textfile, language) that takes as parameters the name of an encrypted text file and the language in the text, and return a string that is the caesar-encrypted version of the text file. The default parameter for the language is english Write a function named infer language (encrypted textfile) that takes as parameters the name of an encrypted text file and return the language of the text in the encrypted file. For this task you may english and dutch. assume that only the following languages are possible: zulu . Write a function named caesar decrypt3(encrypted textfile) that takes as parameter the name of an encrypted text file, and return a string that is the carsar-decrypted version of the text file The above functions mt be adequately documented to receive full credits for the tasks Morever, test your codes extensively to make sure they are working properly Date: February 26, 2018. Email Save

Explanation / Answer

CAESER_ENCRYPT()

def caeser_encrypt(text_file, shift_parameter):
"""Encrypt the string and return the ciphertext
Shift Paramter for right is taken as positive"""
result = ''
  
"""We will find the element in Key and replace by adding the index
For taking left as positive this sring will be reversed"""
key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  
with open('text_file', 'r') as myfile:
data=myfile.read()
  
for l in data.upper():
try:
i = (key.index(l) + shift_parameter) % 26
result += key[i]
except ValueError:
result += l

return result.upper()

CAESER_DECRYPT()

def caeser_decrypt(encrypted_text_file, shift_parameter):
"""Dencrypt the string and return the text
Shift Paramter for right is taken as positive"""
result = ''
  
"""We will find the element in Key and replace by adding the index
For taking left as positive this sring will be reversed"""
  
key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  
with open('text_file', 'r') as myfile:
data=myfile.read()
  
for l in data.upper():
try:
i = (key.index(l) +26 - shift_parameter) % 26 """26 is added to make the substraction Non negative"""
result += key[i]
except ValueError:
result += l

return result.upper()

INFER_SHIFT()

def infer_shift(encrypted_text_file, language='abcdefghijklmnopqrstuvwxyz'):
  
"""for given language we have taken alphabets of the language
to find the alphabets which are not in the given language or not"""
  
  
with open('text_file', 'r') as myfile:
data=myfile.read()
""" If all the elements are in Given language Alphabet function will return True otherwise False """
for i in data:
if i is not in language:
return False
  
return True

INFER_SHIFT_LANGUAGE()

def infer_language(encrypted_text_file):
  
"""for given language we have taken alphabets of the language
to find the alphabets which are not in the given language or not"""
  
english='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  
flag=0;
  
dutch='PUT_DUTCH_ALPHABET_HERE'
  
zulu='PUT_DUTCH_ALPHABET_HERE'
with open('text_file', 'r') as myfile:
data=myfile.read()
  
  
  
"""Cheking Alphabets of English"""
for i in data:
if i is not in english:
flag=1;
break
  
if(flag == 1):
return 'English'
  
"""Cheking Alphabets of Dutch"""
for i in data:
if i is not in dutch:
flag=1;
break
  
if(flag == 1):
return 'Dutch'
  
  
"""Cheking Alphabets of Zulu"""
for i in data:
if i is not in zulu:
flag=1;
break
  
if(flag == 1):
return 'Zulu'

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote