This commit is contained in:
2021-12-30 16:07:16 -05:00
parent 11c06657a5
commit cf183c1bda
9 changed files with 248 additions and 524 deletions

View File

@@ -1,16 +1,15 @@
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Atbash.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 12-25-21
//Modified: 07-25-21
//This is the declaration of the Atbash class
package mattrixwv.CipherStreamJava;
public class Atbash{
public static final String version = "1.0";
private String inputString; //Holds the string that needs encoded or decoded
private String outputString; //The encoded/decoded string
private boolean leaveCapitals; //Whether to respect capitals in the output string
private boolean leaveWhitespace; //Whether to respect whitespace in the output string
private String outputString; //Holds teh current version of the library
//Decodes inputString and stores in outputString
private String decode(){
StringBuilder output = new StringBuilder();
@@ -27,16 +26,7 @@ public class Atbash{
StringBuilder output = new StringBuilder();
//Step through every element in the inputString and shift it the correct amount
for(int cnt = 0;cnt < inputString.length();++cnt){
//Skip any whitespace
if(Character.isWhitespace(inputString.charAt(cnt))){
continue;
}
//Use either uppercase or lowercase for the base
char letterBase = 'a';
if(Character.isUpperCase(inputString.charAt(cnt))){
letterBase = 'A';
}
output.append((char)(inputString.charAt(cnt) + 25 - (2 * (inputString.charAt(cnt) - letterBase))));
output.append((char)(inputString.charAt(cnt) + 25 - (2 * (inputString.charAt(cnt) - 'A'))));
}
outputString = output.toString();
@@ -44,29 +34,15 @@ public class Atbash{
}
//Removes all invalid characters and sets inputString
private void setInputString(String input){
if(!leaveCapitals){
//Convert all letters to uppercase
input = input.toUpperCase();
}
if(!leaveWhitespace){
//Remove all characters except capital letters
input = input.toLowerCase();
}
//Convert all letters to uppercase
input = input.toUpperCase();
//Remove all characters except capital letters
input = input.replaceAll("[^A-Z]", "");
//Save the string
inputString = input;
}
public Atbash(){
reset();
leaveCapitals = false;
leaveWhitespace = false;
}
public Atbash(boolean leaveCapitals, boolean leaveWhitespace){
reset();
this.leaveCapitals = leaveCapitals;
this.leaveWhitespace = leaveWhitespace;
}
public String getInputString(){
return inputString;
}

View File

@@ -1,17 +1,16 @@
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Caesar.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 12-25-21
//Modified: 07-25-21
//This is the declaration of the Caesar class
package mattrixwv.CipherStreamJava;
public class Caesar{
public static final String version = "1.0"; //The current version number for the library
private String inputString; //The string that needs encoded/decoded
private String outputString; //The encoded/decoded string
private int shift; //The amount that you need to shift each letter
private boolean leaveCapitals; //Whether to respect capitals in the output string
private boolean leaveWhitespace; //Whether to respect whitespace in the output string
//Sets shift and makes sure it is within the propper bounds
private void setShift(int shiftAmount){
//If you shift more than 26 you will just be wrapping back around again
@@ -19,12 +18,6 @@ public class Caesar{
}
//Sets the input string
private void setInputString(String inputString){
if(!leaveCapitals){
inputString = inputString.toLowerCase();
}
if(!leaveWhitespace){
inputString = inputString.replaceAll("\\s+", "");
}
this.inputString = inputString;
}
//Encodes the inputString and stores the result in outputString
@@ -99,13 +92,6 @@ public class Caesar{
//Constructor
public Caesar(){
reset();
leaveCapitals = false;
leaveWhitespace = false;
}
public Caesar(boolean leaveCapitals, boolean leaveWhitespace){
reset();
this.leaveCapitals = leaveCapitals;
this.leaveWhitespace = leaveWhitespace;
}
//Returns the inputString
public String getInputString(){
@@ -119,20 +105,6 @@ public class Caesar{
public String getOutputString(){
return outputString;
}
//Returns if capitals should be respected in the output
public boolean getLeaveCapitals(){
return leaveCapitals;
}
public void setLeaveCapitals(boolean leaveCapitals){
this.leaveCapitals = leaveCapitals;
}
//Returns if whitespace should be respected in the output
public boolean getLeaveWhitespace(){
return leaveWhitespace;
}
public void setLeaveWhitespace(boolean leaveWhitespace){
this.leaveWhitespace = leaveWhitespace;
}
//Sets the shift and inputString and encodes the message
public String encode(int shiftAmount, String inputString){
reset();

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Morse.java
//Matthew Ellison
// Created: 07-26-21
//Modified: 07-26-21
// Created: 07-28-21
//Modified: 07-28-21
//This is the declaration of the Morse class
package mattrixwv.CipherStreamJava;
@@ -13,6 +13,7 @@ public class Morse{
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", //M-Z
"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----." //0-9
};
public static final String version = "1.0"; //The current library's version
private String inputString; //The string that needs encoded/decoded
private String outputString; //The encoded/decoded message

View File

@@ -8,6 +8,7 @@ package mattrixwv.CipherStreamJava;
import java.util.ArrayList;
public class Vigenere{
public static final String version = "1.0"; //The current library's version number
protected String inputString; //This is the string that needs encoded/decoded
protected String outputString; //This is the string that is output after encoding/decoding
protected String keyword; //This is the keyword that is resposible for determining the offsets that you change each character by