Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.io.IOException; import javafx.application.Application; //import javafx.application.Application; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Tooltip; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import

import java.io.IOException;
import javafx.application.Application;
//import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class FXDriver extends Application {
/**
* The main method for the GUI example program JavaFX version
* @param args not used
* @throws IOException
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
//call the main scene which is a BorderPane
FXMainPane root = new FXMainPane();
stage.setScene(new Scene(root, 600, 400));
// Set stage title and show the stage.
stage.setTitle("Cybersecurity Encryption and Decryption");
stage.show();
}
}
public class CryptoManager {
private static final char LOWER_BOUND = ' ';
private static final char UPPER_BOUND = '_';
private static final int RANGE = UPPER_BOUND - LOWER_BOUND + 1;
/**
* This method determines if a string is within the allowable bounds of ASCII codes
* according to the LOWER_BOUND and UPPER_BOUND characters
* @param plainText a string to be encrypted, if it is within the allowable bounds
* @return true if all characters are within the allowable bounds, false if any character is outside
*/
public static boolean stringInBounds (String plainText) {
throw new RuntimeException("method not implemented");
}
/**
* Encrypts a string according to the Caesar Cipher. The integer key specifies an offset
* and each character in plainText is replaced by the character \"offset\" away from it
* @param plainText an uppercase string to be encrypted.
* @param key an integer that specifies the offset of each character
* @return the encrypted string
*/
public static String encryptCaesar(String plainText, int key) {
throw new RuntimeException("method not implemented");
}
/**
* Encrypts a string according the Bellaso Cipher. Each character in plainText is offset
* according to the ASCII value of the corresponding character in bellasoStr, which is repeated
* to correspond to the length of plainText
* @param plainText an uppercase string to be encrypted.
* @param bellasoStr an uppercase string that specifies the offsets, character by character.
* @return the encrypted string
*/
public static String encryptBellaso(String plainText, String bellasoStr) {
throw new RuntimeException("method not implemented");
}
/**
* Decrypts a string according to the Caesar Cipher. The integer key specifies an offset
* and each character in encryptedText is replaced by the character \"offset\" characters before it.
* This is the inverse of the encryptCaesar method.
* @param encryptedText an encrypted string to be decrypted.
* @param key an integer that specifies the offset of each character
* @return the plain text string
*/
public static String decryptCaesar(String encryptedText, int key) {
throw new RuntimeException("method not implemented");
}
/**
* Decrypts a string according the Bellaso Cipher. Each character in encryptedText is replaced by
* the character corresponding to the character in bellasoStr, which is repeated
* to correspond to the length of plainText. This is the inverse of the encryptBellaso method.
* @param encryptedText an uppercase string to be encrypted.
* @param bellasoStr an uppercase string that specifies the offsets, character by character.
* @return the decrypted string
*/
public static String decryptBellaso(String encryptedText, String bellasoStr) {
throw new RuntimeException("method not implemented");
}
}
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it and those who are not authorized cannot. In an encryption scheme, the intended information or message, referred to as plaintext, is encrypted using an encryption algorithm - a cipher - generating ciphertext that can be read only if decrypted. The Enigma machines were a family of portable cipher machines with rotor scramblers that became Nazi Germany's principal crypto- system. It was broken by the Polish General Staff's Cipher Bureau in December 1932, with the aid of French-supplied intelligence material obtained from a German spy Enigma machine used by Nazi Germany during World War II Assignment Description Write a Java program to encrypt and decrypt a phrase using two similar approaches, each insecure by modern standards The first approach is called the Caesar Cipher, and is a simple substitution cipher" where characters in a message are replaced by a substitute character. The second approach, due to Giovan Battista Bellaso (b 1505, d 1581), uses a key word, where each character in the word specifies the offset for the corresponding character in the message, with the key word wrapping around as needed. Concepts tested by this assignment Using loops String and character processing ASCII codes . Classes Data Manager class - CryptoManager.java Implement each of the methods specified in this file. This version as provided will print error messages in the console, because they are just the skeletons Each of the methods are static, so there is no need to create an instance of the Data Manager. Document each of your methods with a simple description and document the class with a simple description and your name using in-line comments .... (Just a short sentence fragment will suffice for each documentation string.) The methods are described below. public static boolean stringinBounds (String plain Text This method determines if a string is within the allowable bounds of ASCII codes according to the LOWER BOUND and UPPER BOUND characters. The parameter plain Text is the string to be enerypted. The method returns true if all characters are within the allowable bounds, false if any character is outside public static String encryptCaesar(String plain Text, int key); This method encrypts a string according to the Caesar Cipher. The integer key specifies an offset and each character in plain Text is replaced by the character the specified distance away from it. The parameter plain Text is an uppercase string to be encrypted. The parameter key is an integer that specifies the offset of each character. The method returns the encrypted string. public static String decryptCaesar String encrypted Text, int key This method decrypts a string according to the Caesar Cipher. The integer key specifies an offset and each character in encrypted Text is replaced by the character "offset" characters before it. This is the inverse of the encryptCaesar method. The parameter encrypted Text is the encrypted string to be decrypted, and key is the integer used to encrypt the original text. The method returns the original plain text string. public static String encryptBellaso String plain Text, String bellasoStr). This method encrypts a string according to the Bellaso Cipher. Each character in plain Text is offset according to the ASCII value of the corresponding character in bellaso Str, which is repeated to correspond to the length of plaintext. The method returns the encrypted string public static String decryptBellaso String encrypted Text, String bellaso Str. This method decrypts a string according to the Bellaso Cipher. Each character in encrypted Text is replaced by the character corresponding to the character in bellaso Str. which is repeated to correspond to the length of plain Text. This is the inverse of the encryptBellaso method. The parameter encrypted Text is the encrypted string to be decrypted, and bellaso Str is the string used to encrypt the original text. The method returns the original plain text string Add additional methods if you wish to make your logic easier to follow. . . GUI Driver class - (provided) A Graphical User Interface (GUI) is provided. Be sure that the GUI will compile and run with your methods. The GUI will not compile if your method headers in Crypto Manager.java are not exactly in the format specified. When you first run the application, your methods will all throw exceptions, which will be caught by the GUI and printed out in the console Do not modify the GUI The GUI takes care of capitalizing your input strings. . . . JUnit Test/Test Driver Once your methods are implemented, run the test driver. Ensure that the driver file results in the following output, as shown in RED (of course the output will not be in red when you run the test driver: "THIS TEST SHOULD SUCCEED Is itin bandstre "THIS TEST THAT SHOULD FAIL BECAUSE IS OUTSIDE THE RANGE" Is it in bounds? false "This test should fail because of lowercase letters is it in boondis? false Caesar cipher of "THIS IS ANOTHER TEST should retum "WKLV LVDORWKHUWWHVW WKLV LV#DOR WKHUWWHVW Bellaso cipher of "THIS IS ANOTHER TEST should return "WUVR9F#NERF SUSHED": WU VRSF#NIRE88U-HED Caesar decryption of "WELVALVEDORWKHUWWHVW should return "THIS IS ANOTHER TEST": THIS IS ANOTHER TEST Bellaso decryption of "WU VROEINTRFSSL-HED should return "THIS IS ANOTHER TEST": THIS IS ANOTHER TEST Run the JUnit test file (provided). Ensure that the JUnit tests all succeed. Include Crypto Manager Test.java with the rest of your submission. For GFA (Good Faith Attempt) only include CryptoManagerGFATest.java with the rest of your submission . Assignment Details The first approach is called the Caesar Cipher, and is a simple substitution cipher where characters in a message are replaced by a substitute character. The substitution is done according to an integer key which specifies the offset of the substituting characters. For example, the string ABC with a key of 3 would be replaced by DEF. If the key is greater than the range of characters we want to consider, we wrap around" by subtracting the range from the key until the key is within the desired range. For example, if we have a range from space to "(... ASCII 32 to ASCII 95), and the key is 120, we note that 120 is outside the range, So we subtract 95-32+1-64 from 120, giving 56, which in ASCII is the character '8". If the key is even higher, we can subtract the range from the key over and over until the key is within the desired range Since our specified range does not include lower-case letters, the GUI (provided) will change strings to upper case. You can find the ASCII table at http://www.asciitabile.com, or many other places on the Internet The second approach, due to Giovan Battista Belluso (b 1505, d 1581), uses a key word, where cach character in the word specifies the offset for the corresponding character in the message, with the key word wrapping around as needed So for the string ABCDEFG and the key word CMSC, the key word is first extended to the length of the string. i.e. CMSCCMS. Then A is replaced by "A" offset by "C", I... ASCII 65+67-132. The range of the characters is also specified, and again we'll say to (t.eASCII 32 to ASCII 95). The range is then 95-32-1-64. In our example, the offiset is wrapped" by reducing 132 by the range until it is the allowable range. 132 is adjusted to 132-64-68, or character 'D' in the encrypted please. Then the same logic is applied to the second letter of the plain text "B" shifted by the second letter of the key word 'M'. This results in the character 'O' as the second letter in the encrypted phase, and so on. In each approach if the resulting integer is greater than 95 (the top of our range, the integer is wrapped around" so that it stays within the specified range. The result is "DOVGHSZ". Your program will implement several methods that are specified in the file "CryptoManager.java". A Graphical User Interface is provided, as well as a test file that you should use to make sure your methods work correctly. Be sure to follow the naming exactly, as the tests will not work otherwise. There are several features of Java that we have not yet covered in class. Just follow the syntax specified in this document and in the file Crypto Manager.java. First, the required methods arestatic", which just means that they are available from the class even if an instance has not been created. To call a static method, for example, "public static void my Method:"the syntax is Crypto Manager.my Method ).. Another feature that may be useful in this project is the method chat Auli) on a string, which returns a character at position i of a string (zero-based). So thisString".charAt(3), would return the charts Examples De WOWOWOOD CAN WOOCOUCEMEWA WOOD OLEDO clar 15 HOW MUCH WOOD CAN A WOODOUKOUCH A WOOD OLDECODOLOX Der HOW MUCH WOCO CHA WOODDUCK CHUCKS A WOOD DUCE COULD CHUCE Cyberleyecanwoher 13 Dear Sew X Ceny ponder Uwe HOW MUCH WOOD CAN A WOODCHICK CHUCK A WOOO UCCOULD CHUCK frodig PUMAWIPASTIPRIZORONOW Ghete Cher Drops Cybersecurity Encryption and Decryption Use Caesar cipher Enter plain-text string to encrypt Use Bellaso cipher HOW MUCH WOOD CAN A WOODCHUCK CHUCK IF A WOOD CHUCK COULD CHUCK Encrypted string PTO.JHT,&WTP, RIS,M_TIPRPZOW/MOZINR PUNISHT:RSXOLSTIOW]HW Decrypted string HOW MUCH WOOD CAN A WOODCHUCK CHUCK IF A WOOD CHUCK COULD CHUCK Cyber Key - enter a string for Bellaso Cipher HELLO Clear Exit Encrypt a string Decrypt a string In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it and those who are not authorized cannot. In an encryption scheme, the intended information or message, referred to as plaintext, is encrypted using an encryption algorithm - a cipher - generating ciphertext that can be read only if decrypted. The Enigma machines were a family of portable cipher machines with rotor scramblers that became Nazi Germany's principal crypto- system. It was broken by the Polish General Staff's Cipher Bureau in December 1932, with the aid of French-supplied intelligence material obtained from a German spy Enigma machine used by Nazi Germany during World War II Assignment Description Write a Java program to encrypt and decrypt a phrase using two similar approaches, each insecure by modern standards The first approach is called the Caesar Cipher, and is a simple substitution cipher" where characters in a message are replaced by a substitute character. The second approach, due to Giovan Battista Bellaso (b 1505, d 1581), uses a key word, where each character in the word specifies the offset for the corresponding character in the message, with the key word wrapping around as needed. Concepts tested by this assignment Using loops String and character processing ASCII codes . Classes Data Manager class - CryptoManager.java Implement each of the methods specified in this file. This version as provided will print error messages in the console, because they are just the skeletons Each of the methods are static, so there is no need to create an instance of the Data Manager. Document each of your methods with a simple description and document the class with a simple description and your name using in-line comments .... (Just a short sentence fragment will suffice for each documentation string.) The methods are described below. public static boolean stringinBounds (String plain Text This method determines if a string is within the allowable bounds of ASCII codes according to the LOWER BOUND and UPPER BOUND characters. The parameter plain Text is the string to be enerypted. The method returns true if all characters are within the allowable bounds, false if any character is outside public static String encryptCaesar(String plain Text, int key); This method encrypts a string according to the Caesar Cipher. The integer key specifies an offset and each character in plain Text is replaced by the character the specified distance away from it. The parameter plain Text is an uppercase string to be encrypted. The parameter key is an integer that specifies the offset of each character. The method returns the encrypted string. public static String decryptCaesar String encrypted Text, int key This method decrypts a string according to the Caesar Cipher. The integer key specifies an offset and each character in encrypted Text is replaced by the character "offset" characters before it. This is the inverse of the encryptCaesar method. The parameter encrypted Text is the encrypted string to be decrypted, and key is the integer used to encrypt the original text. The method returns the original plain text string. public static String encryptBellaso String plain Text, String bellasoStr). This method encrypts a string according to the Bellaso Cipher. Each character in plain Text is offset according to the ASCII value of the corresponding character in bellaso Str, which is repeated to correspond to the length of plaintext. The method returns the encrypted string public static String decryptBellaso String encrypted Text, String bellaso Str. This method decrypts a string according to the Bellaso Cipher. Each character in encrypted Text is replaced by the character corresponding to the character in bellaso Str. which is repeated to correspond to the length of plain Text. This is the inverse of the encryptBellaso method. The parameter encrypted Text is the encrypted string to be decrypted, and bellaso Str is the string used to encrypt the original text. The method returns the original plain text string Add additional methods if you wish to make your logic easier to follow. . . GUI Driver class - (provided) A Graphical User Interface (GUI) is provided. Be sure that the GUI will compile and run with your methods. The GUI will not compile if your method headers in Crypto Manager.java are not exactly in the format specified. When you first run the application, your methods will all throw exceptions, which will be caught by the GUI and printed out in the console Do not modify the GUI The GUI takes care of capitalizing your input strings. . . . JUnit Test/Test Driver Once your methods are implemented, run the test driver. Ensure that the driver file results in the following output, as shown in RED (of course the output will not be in red when you run the test driver: "THIS TEST SHOULD SUCCEED Is itin bandstre "THIS TEST THAT SHOULD FAIL BECAUSE IS OUTSIDE THE RANGE" Is it in bounds? false "This test should fail because of lowercase letters is it in boondis? false Caesar cipher of "THIS IS ANOTHER TEST should retum "WKLV LVDORWKHUWWHVW WKLV LV#DOR WKHUWWHVW Bellaso cipher of "THIS IS ANOTHER TEST should return "WUVR9F#NERF SUSHED": WU VRSF#NIRE88U-HED Caesar decryption of "WELVALVEDORWKHUWWHVW should return "THIS IS ANOTHER TEST": THIS IS ANOTHER TEST Bellaso decryption of "WU VROEINTRFSSL-HED should return "THIS IS ANOTHER TEST": THIS IS ANOTHER TEST Run the JUnit test file (provided). Ensure that the JUnit tests all succeed. Include Crypto Manager Test.java with the rest of your submission. For GFA (Good Faith Attempt) only include CryptoManagerGFATest.java with the rest of your submission . Assignment Details The first approach is called the Caesar Cipher, and is a simple substitution cipher where characters in a message are replaced by a substitute character. The substitution is done according to an integer key which specifies the offset of the substituting characters. For example, the string ABC with a key of 3 would be replaced by DEF. If the key is greater than the range of characters we want to consider, we wrap around" by subtracting the range from the key until the key is within the desired range. For example, if we have a range from space to "(... ASCII 32 to ASCII 95), and the key is 120, we note that 120 is outside the range, So we subtract 95-32+1-64 from 120, giving 56, which in ASCII is the character '8". If the key is even higher, we can subtract the range from the key over and over until the key is within the desired range Since our specified range does not include lower-case letters, the GUI (provided) will change strings to upper case. You can find the ASCII table at http://www.asciitabile.com, or many other places on the Internet The second approach, due to Giovan Battista Belluso (b 1505, d 1581), uses a key word, where cach character in the word specifies the offset for the corresponding character in the message, with the key word wrapping around as needed So for the string ABCDEFG and the key word CMSC, the key word is first extended to the length of the string. i.e. CMSCCMS. Then A is replaced by "A" offset by "C", I... ASCII 65+67-132. The range of the characters is also specified, and again we'll say to (t.eASCII 32 to ASCII 95). The range is then 95-32-1-64. In our example, the offiset is wrapped" by reducing 132 by the range until it is the allowable range. 132 is adjusted to 132-64-68, or character 'D' in the encrypted please. Then the same logic is applied to the second letter of the plain text "B" shifted by the second letter of the key word 'M'. This results in the character 'O' as the second letter in the encrypted phase, and so on. In each approach if the resulting integer is greater than 95 (the top of our range, the integer is wrapped around" so that it stays within the specified range. The result is "DOVGHSZ". Your program will implement several methods that are specified in the file "CryptoManager.java". A Graphical User Interface is provided, as well as a test file that you should use to make sure your methods work correctly. Be sure to follow the naming exactly, as the tests will not work otherwise. There are several features of Java that we have not yet covered in class. Just follow the syntax specified in this document and in the file Crypto Manager.java. First, the required methods arestatic", which just means that they are available from the class even if an instance has not been created. To call a static method, for example, "public static void my Method:"the syntax is Crypto Manager.my Method ).. Another feature that may be useful in this project is the method chat Auli) on a string, which returns a character at position i of a string (zero-based). So thisString".charAt(3), would return the charts Examples De WOWOWOOD CAN WOOCOUCEMEWA WOOD OLEDO clar 15 HOW MUCH WOOD CAN A WOODOUKOUCH A WOOD OLDECODOLOX Der HOW MUCH WOCO CHA WOODDUCK CHUCKS A WOOD DUCE COULD CHUCE Cyberleyecanwoher 13 Dear Sew X Ceny ponder Uwe HOW MUCH WOOD CAN A WOODCHICK CHUCK A WOOO UCCOULD CHUCK frodig PUMAWIPASTIPRIZORONOW Ghete Cher Drops Cybersecurity Encryption and Decryption Use Caesar cipher Enter plain-text string to encrypt Use Bellaso cipher HOW MUCH WOOD CAN A WOODCHUCK CHUCK IF A WOOD CHUCK COULD CHUCK Encrypted string PTO.JHT,&WTP, RIS,M_TIPRPZOW/MOZINR PUNISHT:RSXOLSTIOW]HW Decrypted string HOW MUCH WOOD CAN A WOODCHUCK CHUCK IF A WOOD CHUCK COULD CHUCK Cyber Key - enter a string for Bellaso Cipher HELLO Clear Exit Encrypt a string Decrypt a string

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago