Adjusted variable names
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Atbash.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 01-04-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
|
||||
public class Atbash{
|
||||
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 boolean leaveSymbols; //Whether to respect symbols in the output string
|
||||
private boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
private boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
private boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
//Decodes inputString and stores in outputString
|
||||
private String decode(){
|
||||
StringBuilder output = new StringBuilder();
|
||||
@@ -63,15 +63,15 @@ public class Atbash{
|
||||
}
|
||||
//Removes all invalid characters and sets inputString
|
||||
private void setInputString(String input){
|
||||
if(!leaveCapitals){
|
||||
if(!preserveCapitals){
|
||||
//Convert all letters to lowercase
|
||||
input = input.toLowerCase();
|
||||
}
|
||||
if(!leaveWhitespace){
|
||||
if(!preserveWhitespace){
|
||||
//Remove all characters except capital letters
|
||||
input = input.replaceAll("\\s+", "");
|
||||
}
|
||||
if(!leaveSymbols){
|
||||
if(!preserveSymbols){
|
||||
//Remove all non-alpha numeric and whitespace symbols
|
||||
input = input.replaceAll("[^a-zA-Z0-9\\s]", "");
|
||||
}
|
||||
@@ -82,15 +82,15 @@ public class Atbash{
|
||||
|
||||
public Atbash(){
|
||||
reset();
|
||||
leaveCapitals = false;
|
||||
leaveWhitespace = false;
|
||||
leaveSymbols = false;
|
||||
preserveCapitals = false;
|
||||
preserveWhitespace = false;
|
||||
preserveSymbols = false;
|
||||
}
|
||||
public Atbash(boolean leaveCapitals, boolean leaveWhitespace, boolean leaveSymbols){
|
||||
public Atbash(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols){
|
||||
reset();
|
||||
this.leaveCapitals = leaveCapitals;
|
||||
this.leaveWhitespace = leaveWhitespace;
|
||||
this.leaveSymbols = leaveSymbols;
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
}
|
||||
public String getInputString(){
|
||||
return inputString;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Autokey.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 01-04-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
@@ -87,8 +87,8 @@ public class Autokey extends Vigenere{
|
||||
public Autokey(){
|
||||
super();
|
||||
}
|
||||
public Autokey(boolean leaveCapitals, boolean leaveWhitespace, boolean leaveSymbols){
|
||||
super(leaveCapitals, leaveWhitespace, leaveSymbols);
|
||||
public Autokey(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols){
|
||||
super(preserveCapitals, preserveWhitespace, preserveSymbols);
|
||||
}
|
||||
//Encodes inputString using the Autokey cipher
|
||||
public String encode(String key, String input) throws InvalidKeywordException{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/Baconian.java
|
||||
//Mattrixwv
|
||||
// Created: 01-12-22
|
||||
//Modified: 01-12-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,20 +17,20 @@ public class Baconian{
|
||||
));
|
||||
private String inputString; //The string that needs encoded/decoded
|
||||
private String outputString; //The encoded/decoded string
|
||||
private boolean leaveCapitals; //Whether to respect capitals in the output string
|
||||
private boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
|
||||
//Sets the input string
|
||||
private void setInputStringEncode(String inputString){
|
||||
//Remove all whitespace and symbols
|
||||
inputString = inputString.replaceAll("[^A-Za-z]", "");
|
||||
if(!leaveCapitals){
|
||||
if(!preserveCapitals){
|
||||
inputString = inputString.toLowerCase();
|
||||
}
|
||||
|
||||
this.inputString = inputString;
|
||||
}
|
||||
private void setInputStringDecode(String inputString) throws InvalidCharacterException{
|
||||
if(!leaveCapitals){
|
||||
if(!preserveCapitals){
|
||||
inputString = inputString.toLowerCase();
|
||||
}
|
||||
|
||||
@@ -100,11 +100,11 @@ public class Baconian{
|
||||
//Constructor
|
||||
public Baconian(){
|
||||
reset();
|
||||
leaveCapitals = false;
|
||||
preserveCapitals = false;
|
||||
}
|
||||
public Baconian(boolean leaveCapitals){
|
||||
public Baconian(boolean preserveCapitals){
|
||||
reset();
|
||||
this.leaveCapitals = leaveCapitals;
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
}
|
||||
//Returns the outputString
|
||||
public String getOutputString(){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Caesar.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 01-04-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ public class Caesar{
|
||||
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
|
||||
private boolean leaveSymbols; //Whether to respect symbols in the output string
|
||||
private boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
private boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
private boolean preserveSymbols; //Whether to respect symbols 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,13 +19,13 @@ public class Caesar{
|
||||
}
|
||||
//Sets the input string
|
||||
private void setInputString(String inputString){
|
||||
if(!leaveCapitals){
|
||||
if(!preserveCapitals){
|
||||
inputString = inputString.toLowerCase();
|
||||
}
|
||||
if(!leaveWhitespace){
|
||||
if(!preserveWhitespace){
|
||||
inputString = inputString.replaceAll("\\s+", "");
|
||||
}
|
||||
if(!leaveSymbols){
|
||||
if(!preserveSymbols){
|
||||
inputString = inputString.replaceAll("[^a-zA-Z0-9\\s]", "");
|
||||
}
|
||||
this.inputString = inputString;
|
||||
@@ -104,15 +104,15 @@ public class Caesar{
|
||||
//Constructor
|
||||
public Caesar(){
|
||||
reset();
|
||||
leaveCapitals = false;
|
||||
leaveWhitespace = false;
|
||||
leaveSymbols = false;
|
||||
preserveCapitals = false;
|
||||
preserveWhitespace = false;
|
||||
preserveSymbols = false;
|
||||
}
|
||||
public Caesar(boolean leaveCapitals, boolean leaveWhitespace, boolean leaveSymbols){
|
||||
public Caesar(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols){
|
||||
reset();
|
||||
this.leaveCapitals = leaveCapitals;
|
||||
this.leaveWhitespace = leaveWhitespace;
|
||||
this.leaveSymbols = leaveSymbols;
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
}
|
||||
//Returns the inputString
|
||||
public String getInputString(){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Vigenere.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 01-09-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ public class Vigenere{
|
||||
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
|
||||
protected ArrayList<Integer> offset; //Holds the offsets coputed from each character in the keyword
|
||||
protected boolean leaveCapitals; //Whether to respect capitals in the output string
|
||||
protected boolean leaveWhitespace; //Whether to respect whitespace in the output string
|
||||
protected boolean leaveSymbols; //Whether to respect symbols in the output string
|
||||
protected boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
protected boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
protected boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
|
||||
//Uses keyword to calculate the offset for the Caesar cipher for each character
|
||||
protected void setOffset(){
|
||||
@@ -32,13 +32,13 @@ public class Vigenere{
|
||||
}
|
||||
//Sets inputString
|
||||
protected void setInputString(String inputString){
|
||||
if(!leaveCapitals){
|
||||
if(!preserveCapitals){
|
||||
inputString = inputString.toLowerCase();
|
||||
}
|
||||
if(!leaveWhitespace){
|
||||
if(!preserveWhitespace){
|
||||
inputString = inputString.replaceAll("\\s+", "");
|
||||
}
|
||||
if(!leaveSymbols){
|
||||
if(!preserveSymbols){
|
||||
inputString = inputString.replaceAll("[^a-zA-Z0-9\\s]", "");
|
||||
}
|
||||
this.inputString = inputString;
|
||||
@@ -132,16 +132,16 @@ public class Vigenere{
|
||||
public Vigenere(){
|
||||
offset = new ArrayList<Integer>();
|
||||
reset();
|
||||
leaveCapitals = false;
|
||||
leaveWhitespace = false;
|
||||
leaveSymbols = false;
|
||||
preserveCapitals = false;
|
||||
preserveWhitespace = false;
|
||||
preserveSymbols = false;
|
||||
}
|
||||
public Vigenere(boolean leaveCapitals, boolean leaveWhitespace, boolean leaveSymbols){
|
||||
public Vigenere(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols){
|
||||
offset = new ArrayList<Integer>();
|
||||
reset();
|
||||
this.leaveCapitals = leaveCapitals;
|
||||
this.leaveWhitespace = leaveWhitespace;
|
||||
this.leaveSymbols = leaveSymbols;
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
}
|
||||
//Returns the current inputString
|
||||
public String getInputString(){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Morse.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-28-21
|
||||
//Modified: 01-04-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ 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
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Playfair.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-30-21
|
||||
//Modified: 01-09-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ public class Playfair{
|
||||
}
|
||||
|
||||
//Variables
|
||||
private boolean leaveCapitals; //Whether to respect captials in the output string
|
||||
private boolean leaveWhitespace; //Whether to respect whitespace in the output string
|
||||
private boolean leaveSymbols; //Whether to respect symbols in the output string
|
||||
private boolean preserveCapitals; //Whether to respect captials in the output string
|
||||
private boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
private boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
private char replaced; //The letter that will need to be replaced in the grid and any input string or keyword
|
||||
private char replacer; //The letter that replaced replaced in the input string or keyword
|
||||
private char doubled; //The letter that will be placed between double letters in the input string if necessary or to make the string length even
|
||||
@@ -54,13 +54,13 @@ public class Playfair{
|
||||
}
|
||||
|
||||
//Set the options
|
||||
if(!leaveCapitals){
|
||||
if(!preserveCapitals){
|
||||
inputString = inputString.toUpperCase();
|
||||
}
|
||||
if(!leaveWhitespace){
|
||||
if(!preserveWhitespace){
|
||||
inputString = inputString.replaceAll("\\s+", "");
|
||||
}
|
||||
if(!leaveSymbols){
|
||||
if(!preserveSymbols){
|
||||
inputString = inputString.replaceAll("[^a-zA-Z0-9\\s]", "");
|
||||
}
|
||||
|
||||
@@ -295,27 +295,27 @@ public class Playfair{
|
||||
|
||||
public Playfair() throws InvalidCharacterException{
|
||||
reset();
|
||||
leaveCapitals = false;
|
||||
leaveWhitespace = false;
|
||||
leaveSymbols = false;
|
||||
preserveCapitals = false;
|
||||
preserveWhitespace = false;
|
||||
preserveSymbols = false;
|
||||
setReplaced('J');
|
||||
setReplacer('I');
|
||||
setDoubled('X');
|
||||
}
|
||||
public Playfair(boolean leaveCapitals, boolean leaveWhitespace, boolean leaveSymbols) throws InvalidCharacterException{
|
||||
public Playfair(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols) throws InvalidCharacterException{
|
||||
reset();
|
||||
this.leaveCapitals = leaveCapitals;
|
||||
this.leaveWhitespace = leaveWhitespace;
|
||||
this.leaveSymbols = leaveSymbols;
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
setReplaced('J');
|
||||
setReplacer('I');
|
||||
setDoubled('X');
|
||||
}
|
||||
public Playfair(boolean leaveCapitals, boolean leaveWhitespace, boolean leaveSymbols, char replaced, char replacer, char doubled) throws InvalidCharacterException{
|
||||
public Playfair(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols, char replaced, char replacer, char doubled) throws InvalidCharacterException{
|
||||
reset();
|
||||
this.leaveCapitals = leaveCapitals;
|
||||
this.leaveWhitespace = leaveWhitespace;
|
||||
this.leaveSymbols = leaveSymbols;
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
setReplaced(replaced);
|
||||
setReplacer(replacer);
|
||||
setDoubled(doubled);
|
||||
|
||||
Reference in New Issue
Block a user