Updating tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Substitution.java
|
||||
//Mattrixwv
|
||||
// Created: 02-22-22
|
||||
//Modified: 04-18-23
|
||||
//Modified: 05-04-23
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
@@ -13,15 +13,16 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Substitution{
|
||||
protected static Logger logger = LoggerFactory.getLogger(Substitution.class);
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Substitution.class);
|
||||
//Fields
|
||||
protected String inputString; //The string that needs encoded/decoded
|
||||
protected String outputString; //The encoded/decoded string
|
||||
protected String keyword; //The keyword used to encode/decode the input
|
||||
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
|
||||
//Getters
|
||||
protected boolean preserveCapitals; //Persist capitals in the output string
|
||||
protected boolean preserveWhitespace; //Persist whitespace in the output string
|
||||
protected boolean preserveSymbols; //Persist symbols in the output string
|
||||
|
||||
|
||||
//Ensures key constraints are followed
|
||||
protected void setKeyword(String key) throws InvalidKeywordException{
|
||||
@@ -172,6 +173,7 @@ public class Substitution{
|
||||
logger.debug("Decoded message '{}'", outputString);
|
||||
}
|
||||
|
||||
//Constructors
|
||||
public Substitution(){
|
||||
preserveCapitals = false;
|
||||
preserveWhitespace = false;
|
||||
@@ -184,6 +186,23 @@ public class Substitution{
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
reset();
|
||||
}
|
||||
|
||||
//Encodes inputString using the provided key
|
||||
public String encode(String key, String inputString) throws InvalidKeywordException, InvalidInputException{
|
||||
setKeyword(key);
|
||||
setInputString(inputString);
|
||||
encode();
|
||||
return outputString;
|
||||
}
|
||||
//Decodes inputString using the provided key
|
||||
public String decode(String key, String inputString) throws InvalidKeywordException, InvalidInputException{
|
||||
setKeyword(key);
|
||||
setInputString(inputString);
|
||||
decode();
|
||||
return outputString;
|
||||
}
|
||||
|
||||
//Getters
|
||||
public String getInputString(){
|
||||
return inputString;
|
||||
}
|
||||
@@ -193,18 +212,7 @@ public class Substitution{
|
||||
public String getKeyword(){
|
||||
return keyword;
|
||||
}
|
||||
public String encode(String key, String inputString) throws InvalidKeywordException, InvalidInputException{
|
||||
setKeyword(key);
|
||||
setInputString(inputString);
|
||||
encode();
|
||||
return outputString;
|
||||
}
|
||||
public String decode(String key, String inputString) throws InvalidKeywordException, InvalidInputException{
|
||||
setKeyword(key);
|
||||
setInputString(inputString);
|
||||
decode();
|
||||
return outputString;
|
||||
}
|
||||
//Makes sure all variables are empty
|
||||
public void reset(){
|
||||
logger.debug("Resetting fields");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user