Updating tests

This commit is contained in:
2023-05-05 20:19:27 -04:00
parent b3ca4754ea
commit 9c41f10576
45 changed files with 2729 additions and 2239 deletions

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Playfair.java
//Matthew Ellison
// Created: 07-30-21
//Modified: 04-28-23
//Modified: 05-04-23
package com.mattrixwv.cipherstream.polysubstitution;
@@ -16,7 +16,7 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
public class Playfair{
protected static Logger logger = LoggerFactory.getLogger(Playfair.class);
private static final Logger logger = LoggerFactory.getLogger(Playfair.class);
//A class representing the location of a character in the grid
protected class CharLocation{
@@ -35,16 +35,17 @@ public class Playfair{
}
//Fields
protected boolean preserveCapitals; //Whether to respect captials 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
protected char replaced; //The letter that will need to be replaced in the grid and any input string or keyword
protected char replacer; //The letter that replaced replaced in the input string or keyword
protected char doubled; //The letter that will be placed between double letters in the input string if necessary or to make the string length even
protected String inputString; //The message that needs to be encoded/decoded
protected String outputString; //The encoded/decoded message
protected String keyword; //The keyword used to create the grid
protected char[][] grid; //The grid used to encode/decode the message
protected char replaced; //The letter that will need to be replaced in the grid and any input string or keyword
protected char replacer; //The letter that replaced replaced in the input string or keyword
protected char doubled; //The letter that will be placed between double letters in the input string if necessary or to make the string length even
//Settings
protected boolean preserveCapitals; //Persist captials in the output string
protected boolean preserveWhitespace; //Persist whitespace in the output string
protected boolean preserveSymbols; //Persist symbols in the output string
//Set the doubled character
@@ -482,6 +483,7 @@ public class Playfair{
addCharactersToCleanString(output.toString());
}
//Constructor
public Playfair() throws InvalidCharacterException{
reset();
preserveCapitals = false;
@@ -509,6 +511,7 @@ public class Playfair{
setReplacer(replacer);
setDoubled(doubled);
}
//Sets the keyword and inputString and encodes the message
public String encode(String keyword, String input) throws InvalidCharacterException, InvalidInputException{
reset();
@@ -535,7 +538,7 @@ public class Playfair{
outputString = "";
keyword = "";
}
//Gets
//Getters
public char getReplaced(){
return replaced;
}