Question: implement the following method that returns the encrypted String , given a String str and a String key as input. public static String encrypt (

implement the following method that returns the encrypted String , given a String str and a String key as input.

public static String encrypt ( String str , String key )

1) the method takes two String inputs : str and key

2) str is the String to be encrypted , and key is the String that will be used for the encryption of str.Assume that contains only uppercase & lowercase letters and spaces.

3)str will be converted into lowercase before encryption.

4) if the lenght of key is less than 3 or greater than 20, you will randomly create an 8-lenght key using lowercase letter .

5) Each character of str will be encrypted from the firt character to the last one in order

6) For each character encryption of str from the first to the last character , the corresponding character of key will be used.

+ You will start from the first character of key , and proceed to the last one .When you finish all the characters of key to be used , then you will start from the first character again in a cyclic fashion until you finish the encryption of all the characters of str.

+You will shift the character of str to the right by an amount of the corresponding character of key ( 'a' -> no shift , b-> 1 shift , c->2 shifts and so forth).If the encrypted character is greater than 'z' , thwn shift forward in a cyclic fashion that your encrypted character will continue with 'a' after 'z' .i.e.Finally , you must have all the characters as lowercase letters.

+Example-> str = "abyzcdefyz"; key ="aabc"; encryptedString= "abzbcdfhyz";

please java code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!