Hello, me and my classmates are really stumped with our current project. We now we want to use loops instead of an array but we are having trouble setting up the loop in the main file and the tester. Can anyone help? I'll post the instructions below.
INSTRUCTIONS
Several years after mankind has developed letters to convey information to each other, people already started to think about ways to hide this information from those who shouldn't have it. Encryption was born. An early method was easy to conduct manually: Each letter of the alphabet is shifted to the right by a certain number of places. So with 12 shifts the letter A becomes the letter M, B becomes N, etc. The letter N becomes Z and O would then become A again. Here is the method for the shift value of 12:
Original: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Code: MNOPQRSTUVWXYZABCDEFGHIJKL
Each letter in the first line is then replaced by the corresponding letter in the second line. So the word "ENCRYPTION" could be shifted by 12 giving the encrypted word "QZODKBFUAZ". Interestingly enough, if you then shift "QZODKBFUAZ" by 14, you'll get... You can figure it out, I'm sure!
Yep! Shifting by a value of n encrypts a message which then can be decrypted by shifting it by 26 - n. Obviously this method only works with uppercase letters and shifts between 1 and 25 including – shifting by 0 or 26 is not (!) an effective encryption method!
And how do I break the encryptions?
Assume we want to decrypt "YFIXIDLKBK". You run the code "YFIXIDLKBK" through all values between 1 and 25. One of the 25 results will make sense. These kinds of attacks against an encryption method are called "brute force" attacks, because they do not attempt to use any sophisticated statistical methods, they just try all possible values and rely on the human brain to figure out the right one.
Project Requirements:
Write a class StringShifter with one instance field text of type String. It has one constructor public StringShifter(String initialText) (as usual!). It also has a method public String shift(int n) which returns the text shifted right by n positions. If n is not between 1 and 25, the original text is returned.
Write a little tester that quickly tests the example from the background information, especially making sure that the encryption and decryption works as expected!
Write a class CodeBreaker with only a main method that generates all 25 solutions by using a loop – not by manually calling the methods 25 times.
Try to decrypt "KZINVXJGV". Run your program. The program must have 25 lines of words. Take the screenshot and submit.