Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

For this project you will be writing methods of encrypting and decrypting text.

PART 1 - NORMALIZE TEXT

The first thing we will do is normalize our input message so that it's easier to work with.

Using a method called normalizeText() which does the following:

1. Removes all the spaces from your text

2. Remove any punctuation (. , : ; ' " ! ? ( ) )

3. Turn all lower-case letters into upper-case letters

4. Return the result.

The call

normalizeText("This is some "really" great. (Text)!?")

should return

"THISISSOMEREALLYGREATTEXT"

PART 2 - CAESAR CIPHER

Next we'll be writing a Caesar Cipher. The Caesar cipher is just about the simplest encryption algorithm out there. A Caesar encription "shifts" each individual character forward by a certain number or "key". Each letter in the alphabet is shifted to the letter in the alphabet that is "key" places past the original letter. With a shift value of +1, the string "ILIKEZOOS" would be rendered as "JMJLFAPPT."

Using a method called caesarify that takes two parameters. The first argument is a string you want to encrypt, and the second is an integer that contains the shift value or "key". The function should return a string, which is the input string encrypted with the Caesar cypher using the shift value passed in its second argument. You may assume that the input string is normalized.

  • Note that the alphabet "wraps around", so with a shift value of +1 the "Z" in ZOOS became an A.
  • You can also have negative shift values, which cause the alphabet to previous letters. With a -1 shift, the string "ILIKEAPPLES" would turn into "HKHJDZOOKDR."

We will provide you with a function called shiftAlphabet. This function takes one argument, an integer to specify the shift value, and returns a string, which is the uppercase alphabet shifted by the shift value. So if you call shiftAlphabet(2), you will get back the following string: "CDEFGHIJKLMNOPQRSTUVWXYZAB"

Here is the implementation for shiftAlphabet, which you can just paste into your java file:

public static String shiftAlphabet(int shift) {

   int start = 0;

   if (shift < 0) {

       start = (int) 'Z' + shift + 1;

   } else {

       start = 'A' + shift;

   }

   String result = "";

   char currChar = (char) start;

   for(; currChar <= 'Z'; ++currChar) {

       result = result + currChar;

   }

   if(result.length() < 26) {

       for(currChar = 'A'; result.length() < 26; ++currChar) {

           result = result + currChar;

       }

   }

   return result;

}

PART 3 - CODEGROUPS

Traditionally, encrypted messages are broken into equal-length chunks, separated by spaces and called "code groups."

Using a method called groupify which takes two parameters. The first parameter is the string that you want to break into groups. The second argument is the number of letters per group. The function will return a string, which consists of the input string broken into groups with the number of letters specified by the second argument. If there aren't enough letters in the input string to fill out all the groups, you should "pad" the final group with x's. So groupify ("HITHERE", 2) would return "HI TH ER Ex".

  • You may assume that the input string is normalized.
  • Note that we use lower-case 'x' here because it is not a member of the (upper-case) alphabet we're working with. If we used upper-case 'X' here we would not be able to distinguish between an X that was part of the code and a padding X.

PART 4 - PUTTING IT ALL TOGETHER

Using a function called encryptString which takes three parameters: a string to be encrypted, an integer shift value, and a code group size. Your method should return a string which is its cyphertext equivalent. Your function should do the following:

  • Call normalizeText on the input string.
  • Call obify to obfuscate the normalized text.
  • Call caesarify to encrypt the obfuscated text.
  • Call groupify to break the cyphertext into groups of size letters.
  • Return the result

PART 5 - HACKER PROBLEM - DECRYPT

This part is not required for course credit.

Using a method called ungroupify which takes one parameter, a string containing space-separated groups, and returns the string without any spaces. So if you call ungroupify("THI SIS ARE ALL YGR EAT SEN TEN CEx") you will return "THISISAREALLYGREATSENTENCE"

Now using a function called decryptString which takes three parameters: a string to be decrypted and the integer shift value used to encrypt the string, and returns a string which contains the (normalized) plaintext. You can assume the string was encrypted by a call to encryptString().

So if you were to call

String cyphertext = encryptString("Who will win the election?", 5, 3);

String plaintext = decryptString(cyphertext, 5);

... then you'll get back the normalized input string "WHOWILLWINTHEELECTION".

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92821653
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Risky business how can us companies protect their digital

Risky Business: How Can U.S. Companies Protect their Digital Assets Overseas? Prepare a 3 to 5 paragraph briefing statement that can be used to answer the above question. Your audience will be attendees at a conference f ...

Respond to the followingin a bst what is the complexity

Respond to the following: In a BST, what is the complexity required to remove the minimum element? In a BST, what is the complexity required to find (but not remove) the minimum element? In a heap, what is the complexity ...

Command to define an environmental variable name time with

Command to define an environmental variable name "time" with initial value "11:00PM". (Unix)

Systems analysis project 12 please answer the 2 questions1

Systems analysis project 12: please answer the 2 questions 1. Develop a process for managing change requests and design a form to handle a generic change request. The process should include a contingency plan for changes ...

Do you believe corporation pose as a risk to our national

Do you believe corporation pose as a risk to our national economy and to domestic employees based upon external shocks to our economy as well as government regulations and Obamacare?

Now assume that a country a takes 100 hours to produce 20

Now assume that a country A takes 100 hours to produce 20 aircraft or 10 jet engines and country B takes 100 hour to produce 15 aircraft or 5 jet engines. Which country has an absolute advantage in which product? Does ei ...

How many electrons in a tellurium te atom have a principal

How many electrons in a tellurium (Te) atom have a principal quantum number of n = 4 and a magnetic quantum number of m l  = 0? a)2 b) 3 c) 6 d) 9 e) 18 Why does Beryllium (Be) have a positive electron affinity? ( That i ...

Question suppose that a computer can execute 1 billion

Question : Suppose that a computer can execute 1 billion instructions/sec and that a system call takes 1000 instructions, including the trap and all the context switching. How many system calls can the computer execute p ...

String cyclic leftshift string s int k that creates and

String cyclic LeftShift (String s, int k) that creates and returns a string in which character of s has been moved left k steps, so that the characters that would "fall off' the left end are appended to the right. For ex ...

Question suppose that a table has 9 columns it is known

Question : Suppose that a table has 9 columns. It is known that we only need to provide values for 4 columns explicitly to insert a new row successfully. Assume that there are n columns with default values and there are ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As