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