Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE CODE IN JAVA USING THE DECORATOR DESIGN PATTERN 2. Implement the following using the Decorator pattern. Consider that a line of text is to
PLEASE CODE IN JAVA USING THE DECORATOR DESIGN PATTERN
2. Implement the following using the Decorator pattern. Consider that a line of text is to be encrypted possibly multiple times using cascading encryption. Remember ... identify yourself via @author... Your code must work with the following Driver class: import java.io. ; import java.util.Scanner; public class Driver \{ public static void main(String[] args) throws IOException \{ Scanner kb=new Scanner(new File("readme.txt")); while (kb.hasNext())\{ String statement = kb. . extLine(); Message message = new UserMessage(); message.send(statement); System.out.println(">>Leet > "); Message messagel; messageL = new LeetSimplified(new UserMessage()); messagel.send(statement); System.out.println(">>Caesar>>"); Message messageC; messageC = new Caesar (new UserMessage()); messageC.send(statement); System.out.println(">>ROT13>>"); Message messageR; messageR = new Rot13(new UserMessage()); messageR.send(statement); System.out.println(">>ROT13 then Leet >>); Message MessageRL; MessageRL = new Rot13(new LeetSimplified(new UserMessage())); MessageRL.send(statement); System.out.println(" > ROT13 then ROT13>>"); Message MessagerR; MessageRR = new Rot13 (new Rot13 (new UserMessage()); MessageRR.send(statement); 3 3 \} You must implement the following simple encryption schemes: a) Leet(Simplified) https://en.wikipedia.org/wiki/Leet This is a simplified version of Leet where we replace the following characters with the number shown. b) ROT13 https://en.wikipedia.org/wiki/ROT13 In ROT13, letters of the alphabet are changed with each other using a simple pattern. For example, A changes to N, B changes to O,C changes to P, and so on. Each letter is "rotated" by 13 spaces. Using the ROT13 cipher, the words simple english wikipedia becomes fvzcyr ratyvfu jvxverqun. The ROT13 cipher is very easy to decrypt. Because there are 26 letters in the English alphabet, if a letter is rotated two times by 13 letters each time, the original letter will be obtained. So applying the ROT13 cipher a second time brings back the original text. c) Caesar cipher https://en.wikipedia.org/wiki/Caesar_cipher When he communicated with his army, Julius Caesar sometimes used what is known as the Caesar cipher today. This cipher works by shifting the position of letters: each letter is rotated by 3 positions. Example the quick brown fox jumps over the lazy dog > qeb nrfzh yoltk clu grjmp Isbo qeb ixwv aldStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started