Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is Assignment 1: You will write 2 programs. One will encode a message and the other will decode the message. A message is a

image text in transcribedimage text in transcribedimage text in transcribed

Here is Assignment 1: You will write 2 programs. One will encode a message and the other will decode the message. A message is a string that consists of lowercase English words and full stops and question marks and spaces. There will be no uppercase letters and no digits and no special characters except spaces and full stops. For example, "once you agree with your boss on the blueprint go into details on each component. design the most critical components first. Your task will be: First One: Encryption: First, separate the sentences by reaching a full stop or a question mark. After that, for each sentence, separate the words by reaching a space or a full stop or a question mark. And then for every word, replace a with 1, b with 2 , c with 3 and so on. Replace full stop with 27 and question marks with 28 . Then compute the hash values of every word. Take 29 as your hashing base. Write the hash values of the words of a single sentence in a single line in a file. For the next sentence, write the hash values of the words of that sentence in the next line of the file. For example, look at the following message "hi mike. how r u? how is it going?" We can break this message down to 2 sentences. "hi mike." "how r u?" "how is it going?" Notice that, there is a space at the end of the first sentence and at the beginning of the second sentence. We will ignore that. There is also a space at the end of the second sentence and before the third sentence. We will ignore that too. Notice that, we do not consider full stops or question marks as separate words. We attach them at the end of the last word of a sentence. Then we can break down the Then we can use the mappings to get the sentences look like this: [8,9],[13,9,11,5,27][8,15,23],[18],[21,28][8,15,23],[9,19],[9,20],[7,15,9,14,7,28]. Then we can hash each word into a single decimal number and get the sentences to look like this and you will have to write the sentences into the file in this format: 241,94235777186,18,6377186,280,281,1544187642. Second One: Decryption: You know the base/radix you used to encrypt the words. You also know the character-to-number mapping used in the encryption. Open the file where you kept the encrypted values of the messages. Read line by line. From each line, reconstruct the sentences by using decryption. Transform the hash value of a word into an ordered group of characters. And this way, recover the whole message. For example, You read the first line of the file, so you get the first sentence which is: 241,9423577Then you, compute that 241=8291+929 0So, you understand that, the word is [8,9] or simply put, "hi". Then you compute that 9423577=13294+9293+11292+5291+27290. So, you realize that the word is [13,9,11,5,27] or just "mike.". So, you output the sentence, "hi mike.". This way, you read each line and output each sentence of the message. Clarifications: 1. Your message before encryption and decryption should be exactly identical. 2. None of the words given will be longer than 10 digits. Use long int data type to avoid overflow. 3. You can use any of these languages: Python, C++, and JAVA. 4. Plagiarism will be severely punished and you will not be able to bargain. 6. Notice that the submission link is at the very end of this page. Comments: 1. Imagine you are creating a messenger. The user writes something. Before you send the text to another user, you must encrypt the text. Before the other user sees the text, you must decrypt it. Because that way, you can prevent others from hacking into the connection and reading the texts. They will not be able to decrypt your messages because only you know the hashing base and only you know the character mappings. The encryption technique we used here is very basic and hackers will be able to hack our messages but this is good for assignments and studies because it's simple. In a realworld scenario, they use far better encryption and decryption algorithms and hash functions

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

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

ISBN: 1461368332, 978-1461368335

More Books

Students also viewed these Databases questions