Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(I need help please ????) Problem: Ever since the human race developed language, we have used codes and ciphers to obscure our messages. The Greeks

(I need help please ????)

Problem:

Ever since the human race developed language, we have used codes and ciphers to obscure our messages. The Greeks and Egyptians used codes to transfer private communications, forming the foundation of modern code breaking. The process of converting data into a code is called encryption. It involves substituting one letter for another letter, according to some predetermined rule.

In this assignment, you will write a program to encrypt (encode) a text file. To make the encrypted code hard to decipher, you have to apply the Cesar shift method for substituting cipher. The Cesar shift method is simple to use and understand, but very difficult to crack, making it one of the other fundamental code systems. It shifts the entire alphabet a certain number of places in one direction. For example if we need to shift a letter by 3 places, then A becomes D, B becomes A, and Z becomes C. For your encryption method, you need to shift each letter of the alphabet (lower-case only) by 25 in order to create the cipher-text of reverse alphabet. That is:

Alphabet

a

b

c

d

e

f

g

h

i

j

k

l

m

n

o

p

q

r

s

t

u

v

w

x

y

z

Ciphertext

Alphabet

z

y

x

w

v

u

t

s

r

q

p

o

n

m

l

k

j

i

h

g

f

e

d

c

b

a

Figure 1 The Cesar Shift

Encryption:

Your need to apply these rules to encrypt your data: Knowing that a sentence does not start with a number.

1) Write the first word in a paragraph in reverse order (e.g. Python becomes nohtyP) then make it the last word of the paragraph in your encrypted text.

2) For the remaining words of a paragraph (i.e. except the first word in point 1 above), do the following:

o Apply Cesar shift on the last letter of a word (use figure 1 to replace the letter with its corresponding cipher-text alphabet) then move it to the front of the word

o The most common letter used in English is the letter "e" followed by "t" and "a". Thus, for the rest of the letters in the word, replace a, e, and t with &, $, and ! in that order.

o Example: assume your words is is my first programing course when encrypted it becomes Hi Bm Gfirs Tprogr&min Vcours

o Numbers are encoded as binary numbers (i.e. convert each decimal into binary digits); assuming only integer values are available on your data. (e.g. 2101 become 100000110101)

o Do not encrypt any non-alphanumeric data; i.e. special characters as (!,@,#,%,..ect) will remain the same in both original and encrypted files.

3) Your encrypted data must have the same number of paragraphs and characters as in the original data.

Example: assume your sentence is Python is my first programing course 2101. After encryption it becomes: Hi Bm Gfirs Tprogr&min Vcours 100000110101 nohtyP

(nohtyP): First word Python is reversed and become last word of a line

(Hi Bm Gfirs Tprogr&min Vcours 100000110101): For remaining words in a sentence (without first word) apply rule (2) above

In this assignment, at first you need to ask the user to enter his/her password. You should display the password rules and allow the user to encrypt a text file if and only if his/her password is valid. Figure 3 shows how the rules are displayed on the screen. If a user entered an invalid password, you need to display a proper message (as shown in figure 3) and then continuously display the rules until the user enter a valid password.

Your Python program should have the following functions:

a. main( ): the main function displays the selection menu to the user by calling displayRules() function and ask a user twice for a password (the password and confirmed password). It then validate password by calling validatePassword (password,confirmpass) function. If the users password is invalid, the program has to display rule menu again and ask for new password. When a correct password is provided, the program asks the user to enter their input and output file names and then call encode (inputFilename, outputFileName) function. If the input file does not exist the exception handling should deal with that situation.

b. displayRules( ): to print the password rules as shown in figure 3. This function does not return any value.

c. validatePassword (password,confirmpass): check if password following the rules as described in figure 3 above and print proper error message if not before returning a Boolean value. The error message should tell the user why his/her password is invalid.

d. encode (inputFilename, outputFileName): this function open input and output files. You should use appropriate exceptions to handle non-existing files. The function separates paragraphs. For each paragraph it calls reverseWord(word) function that takes a word and return it back in reverse order letter by letter. It also calls encodeLine(words) function to encode the remaining words of a paragraph as explained earlier. It forms the final encrypted text corresponds to the original data and then write the results in the output file.

continue next page

e. encodeLine(words): This function do the actual encryption of a paragraph word by word. It calls decToBinary(number) function to convert decimal to binary string digits. Otherwise, it calls encodeWord(word). It gathers the encrypted words in a line that is then returned to encode( ) function.

f. encodeWord(word) function applies the Cesar shift method and replaces the common used letters as mentioned in rule (2) and finally return the encoded word.

plz> i need help using python program!!!!!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago