Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

S2_OneTimePad For all three problems, store the alphabet in a static array that contains only capital letters, i.e. the length of the array should be

S2_OneTimePad

For all three problems, store the alphabet in a static array that contains only capital letters, i.e. the length of the array should be 26, and you may have to convert any input text to uppercase.

Your alphabet should be stored as follows, but with all the alphabet:

final static char alphabet [] = {A, B, C};

You should have a method to convert a letter to an index of the alphabet array, and vice versa.

IMPORTANT NOTE: To get credit for the Hard, you only have to do the Hard part. To get credit for the Medium, you only have to do the Medium part. Code from the easy should be able to be re-used in the medium part and likewise for the hard part. So, if you do the Easy part and later decide to do the Medium, you haven't wasted your time. The difficulty of this problem varies based on the parts you complete, but you may only count it once (easy OR medium OR hard).

Easy:

A simple way to encrypt text is to simply shift each letter forward by a given number, n.

When n=13, and using just letters, the message is:

image text in transcribed

You are to create a program that prompts you to enter a message and the value of n, and then displays the cipher text. You must also have a program that decrypts the cipher text given an n value.

Medium:

The easy problem's encryption is easily broken. To make this type of encryption unbreakable, you simply need to change the n for each letter of the message.

image text in transcribed

You are to write a program that takes a message as input and then generates n values for each letter and the number of the input message, and displays the cipher-text. Then you are to create a program that decrypts the cipher text, given the n values. To make this as easy to use as possible, print the n values and cipher-text one line each. This will make it easier to copy and paste from your encrypting program to your decrypting program.

Example input:

Message: Meet me at three.

Key: 2,13,22,1,3,17,15,19,25,1,14,12,7

Cipher Text: ORAU PV PM SIFQL.

Hard:

One of the problems faced in cryptography, is how do you transfer the key?

The medium problem would require you to transmit a new set of n values for each message. Instead, you are to generate a large set of n values that is defined by the user, and then store the n values in a file.

Your encrypting suite should have three programs: A key generator, an encryptor, and decryptor. They key generator should allow the user to generate a key file with a specified number of n values. The encrypting program should ask the user for the location of the key file and the message, and then should output a file containing the encrypted text and update the current position of the key file. The decryptor should prompt the user to specify the location of the key file and the location of the encrypted text file, and display the decrypted text.

Example key file:

4

12,7,23,2,13,22,1,3,17,15,19,25,1,14,12,7,4,5,2,6,8

The first line is the current position of where to start from, and the next line is the n values.

Encrypted file:

4

ORAU PV PM SIFQL

The first line is the position in the key file that n values are from, and the second line is the cipher text.

After encrypting the message, the key file's position will be updated to the current position. In the example above, the new key file will look like:

17

12,7,23,2,13,22,1,3,17,15,19,25,1,14,12,7,4,5,2,6,8

When the decrypting program reads the encrypted file, it knows where in the key file to start reading n values.

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

What is electric dipole explain with example

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago

Question

Question How are VEBA assets allocated when a plan terminates?

Answered: 1 week ago

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago