Added ADFGX cipher

This commit is contained in:
2022-01-25 23:26:05 -05:00
parent 87c5eb093e
commit 57f5d350da
2 changed files with 623 additions and 0 deletions

View File

@@ -0,0 +1,173 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGX.java
//Mattrixwv
// Created: 01-25-22
//Modified: 01-25-22
package com.mattrixwv.CipherStreamJava.combination;
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
import com.mattrixwv.CipherStreamJava.polySubstitution.Columnar;
import com.mattrixwv.CipherStreamJava.polySubstitution.PolybiusSquare;
public class ADFGX{
private boolean preserveCapitals;
private boolean preserveWhitespace;
private boolean preserveSymbols;
private String inputString;
private String outputString;
private String squareKeyword;
private String keyword;
private PolybiusSquare polybiusSquare;
private Columnar columnar;
private void setSquareKeyword(String squareKeyword) throws InvalidKeywordException{
if(squareKeyword == null){
throw new InvalidKeywordException("Square Keyword cannot be null");
}
this.squareKeyword = squareKeyword;
}
private void setKeyword(String keyword) throws InvalidKeywordException{
if(keyword == null){
throw new InvalidKeywordException("Keyword cannot be null");
}
this.keyword = keyword;
}
private void setInputString(String inputString) throws InvalidInputException{
if(inputString == null){
throw new InvalidInputException("Input cannot be null");
}
if(!preserveCapitals){
inputString = inputString.toUpperCase();
}
if(!preserveWhitespace){
inputString = inputString.replaceAll("\\s+", "");
}
if(!preserveSymbols){
inputString = inputString.replaceAll("[^a-zA-Z\\s]", "");
}
this.inputString = inputString;
if(this.inputString.isBlank()){
throw new InvalidInputException("Input cannot be blank");
}
}
private void formatOutputStringEncode(){
StringBuilder output = new StringBuilder();
int outputLocation = 0;
for(char ch : inputString.toCharArray()){
if(Character.isUpperCase(ch)){
output.append(Character.toUpperCase(outputString.charAt(outputLocation++)));
output.append(Character.toUpperCase(outputString.charAt(outputLocation++)));
}
else if(Character.isLowerCase(ch)){
output.append(Character.toLowerCase(outputString.charAt(outputLocation++)));
output.append(Character.toLowerCase(outputString.charAt(outputLocation++)));
}
else{
output.append(ch);
}
}
outputString = output.toString();
}
private void formatOutputStringDecode(){
StringBuilder output = new StringBuilder();
int outputLocation = 0;
for(int inputLocation = 0;inputLocation < inputString.length();++inputLocation){
char ch = inputString.charAt(inputLocation);
if(Character.isUpperCase(ch)){
output.append(Character.toUpperCase(outputString.charAt(outputLocation++)));
++inputLocation;
}
else if(Character.isLowerCase(ch)){
output.append(Character.toLowerCase(outputString.charAt(outputLocation++)));
++inputLocation;
}
else{
output.append(ch);
}
}
outputString = output.toString();
}
private String encode() throws InvalidCharacterException, InvalidInputException, InvalidKeywordException{
//Encode the input with polybius
String polybiusOutput = polybiusSquare.encode(squareKeyword, inputString);
//Change polybius to use the correct symbols
polybiusOutput = polybiusOutput.replaceAll("1", "A").replaceAll("2", "D").replaceAll("3", "F").replaceAll("4", "G").replaceAll("5", "X");
//Encode polybius's output with columnar
String columnarOutput = columnar.encode(keyword, polybiusOutput);
outputString = columnarOutput;
//Add whatever is needed to the output string
formatOutputStringEncode();
return outputString;
}
private String decode() throws InvalidKeywordException, InvalidCharacterException, InvalidInputException{
//Decode the input with columnar
String columnarOutput = columnar.decode(keyword, inputString);
//Change the symbols to the correct ones for polybius
columnarOutput = columnarOutput.replaceAll("A", "1").replaceAll("D", "2").replaceAll("F", "3").replaceAll("G", "4").replaceAll("X", "5");
//Decode with polybius
String polybiusOutput = polybiusSquare.decode(squareKeyword, columnarOutput);
outputString = polybiusOutput;
//Add whatever is needed to the output string
formatOutputStringDecode();
return outputString;
}
public ADFGX() throws InvalidCharacterException{
preserveCapitals = false;
preserveWhitespace = false;
preserveSymbols = false;
reset();
}
public ADFGX(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols) throws InvalidCharacterException{
this.preserveCapitals = preserveCapitals;
this.preserveWhitespace = preserveWhitespace;
this.preserveSymbols = preserveSymbols;
reset();
}
public String encode(String squareKeyword, String keyword, String inputString) throws InvalidKeywordException, InvalidInputException, InvalidCharacterException{
setSquareKeyword(squareKeyword);
setKeyword(keyword);
setInputString(inputString);
return encode();
}
public String decode(String squareKeyword, String keyword, String inputString) throws InvalidKeywordException, InvalidInputException, InvalidCharacterException{
setSquareKeyword(squareKeyword);
setKeyword(keyword);
setInputString(inputString);
return decode();
}
public String getInputString(){
return inputString;
}
public String getOutputString(){
return outputString;
}
public String getSquareKeyword(){
return squareKeyword;
}
public String getKeyword(){
return keyword;
}
public void reset() throws InvalidCharacterException{
polybiusSquare = new PolybiusSquare(false, false);
columnar = new Columnar(false, false, false, true, 'B');
inputString = "";
outputString = "";
squareKeyword = "";
keyword = "";
}
}

View File

@@ -0,0 +1,450 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamjava/combination/TestADFGX.java
//Mattrixwv
// Created: 01-25-22
//Modified: 01-25-22
package com.mattrixwv.CipherStreamJava.combination;
import static org.junit.Assert.assertEquals;
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
import org.junit.Test;
public class TestADFGX{
@Test
public void testEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(true, true, true);
//Test lowercase encoding
String inputString = "messagetoencode";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
String output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed lowercase encoding.", correctOutput, output);
//Test uppercase encoding
inputString = "MESSAGETOENCODE";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed uppercase encoding.", correctOutput, output);
//Test whitespace encoding
inputString = "message to encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "aagagadfagaxxd axdx adafafxddgdf";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed whitespace encoding.", correctOutput, output);
//Test symbol encoding
inputString = "message*to+encode-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "aagagadfagaxxd*axdx+adafafxddgdf-";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed symbol encoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol encoding
inputString = "Message to^encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAgagadfagaxxd axdx^adafafxddgdf";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed mixed case, whitesapce, and symbol encoding.", correctOutput, output);
}
@Test
public void testNoCapitalEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(false, true, true);
//Test lowercase encoding
String inputString = "messagetoencode";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
String output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital lowercase encoding.", correctOutput, output);
//Test uppercase encoding
inputString = "MESSAGETOENCODE";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital uppercase encoding.", correctOutput, output);
//Test whitespace encoding
inputString = "message to encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXD AXDX ADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital whitespace encoding.", correctOutput, output);
//Test symbol encoding
inputString = "message*to+encode-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXD*AXDX+ADAFAFXDDGDF-";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital symbol encoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol encoding
inputString = "Message to^encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXD AXDX^ADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital mixed case, whitesapce, and symbol encoding.", correctOutput, output);
}
@Test
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(true, false, true);
//Test lowercase encoding
String inputString = "messagetoencode";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
String output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace lowercase encoding.", correctOutput, output);
//Test uppercase encoding
inputString = "MESSAGETOENCODE";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace uppercase encoding.", correctOutput, output);
//Test whitespace encoding
inputString = "message to encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace whitespace encoding.", correctOutput, output);
//Test symbol encoding
inputString = "message*to+encode-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "aagagadfagaxxd*axdx+adafafxddgdf-";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace symbol encoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol encoding
inputString = "Message to^encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAgagadfagaxxdaxdx^adafafxddgdf";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace mixed case, whitesapce, and symbol encoding.", correctOutput, output);
}
@Test
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(true, true, false);
//Test lowercase encoding
String inputString = "messagetoencode";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
String output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol lowercase encoding.", correctOutput, output);
//Test uppercase encoding
inputString = "MESSAGETOENCODE";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol uppercase encoding.", correctOutput, output);
//Test whitespace encoding
inputString = "message to encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "aagagadfagaxxd axdx adafafxddgdf";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol whitespace encoding.", correctOutput, output);
//Test symbol encoding
inputString = "message*to+encode-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol symbol encoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol encoding
inputString = "Message to^encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAgagadfagaxxd axdxadafafxddgdf";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol mixed case, whitesapce, and symbol encoding.", correctOutput, output);
}
@Test
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(false, false, false);
//Test lowercase encoding
String inputString = "messagetoencode";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
String output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed lowercase encoding.", correctOutput, output);
//Test uppercase encoding
inputString = "MESSAGETOENCODE";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed uppercase encoding.", correctOutput, output);
//Test whitespace encoding
inputString = "message to encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed whitespace encoding.", correctOutput, output);
//Test symbol encoding
inputString = "message*to+encode-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed symbol encoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol encoding
inputString = "Message to^encode";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
output = cipher.encode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed mixed case, whitesapce, and symbol encoding.", correctOutput, output);
}
@Test
public void testDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(true, true, true);
//Test lowercase decoding
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "messagetoencode";
String output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed lowercase decoding.", correctOutput, output);
//Test uppercase decoding
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed uppercase decoding.", correctOutput, output);
//Test whitespace decoding
inputString = "aagagadfagaxxd axdx adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "message to encode";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed whitespace decoding.", correctOutput, output);
//Test symbol decoding
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "message*to+encode-";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed symbol decoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol decoding
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "Message to^encode";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed mixed case, whitesapce, and symbol decoding.", correctOutput, output);
}
@Test
public void testNoCapitalDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(false, true, true);
//Test lowercase decoding
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "MESSAGETOENCODE";
String output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital lowercase decoding.", correctOutput, output);
//Test uppercase decoding
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital uppercase decoding.", correctOutput, output);
//Test whitespace decoding
inputString = "aagagadfagaxxd axdx adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGE TO ENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital whitespace decoding.", correctOutput, output);
//Test symbol decoding
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGE*TO+ENCODE-";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital symbol decoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol decoding
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGE TO^ENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no capital mixed case, whitesapce, and symbol decoding.", correctOutput, output);
}
@Test
public void testNoWhitespaceDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(true, false, true);
//Test lowercase decoding
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "messagetoencode";
String output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace lowercase decoding.", correctOutput, output);
//Test uppercase decoding
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace uppercase decoding.", correctOutput, output);
//Test whitespace decoding
inputString = "aagagadfagaxxd axdx adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "messagetoencode";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace whitespace decoding.", correctOutput, output);
//Test symbol decoding
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "message*to+encode-";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace symbol decoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol decoding
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "Messageto^encode";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no whitespace mixed case, whitesapce, and symbol decoding.", correctOutput, output);
}
@Test
public void testNoSymbolDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(true, true, false);
//Test lowercase decoding
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "messagetoencode";
String output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol lowercase decoding.", correctOutput, output);
//Test uppercase decoding
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol uppercase decoding.", correctOutput, output);
//Test whitespace decoding
inputString = "aagagadfagaxxd axdx adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "message to encode";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol whitespace decoding.", correctOutput, output);
//Test symbol decoding
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "messagetoencode";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol symbol decoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol decoding
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "Message toencode";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed no symbol mixed case, whitesapce, and symbol decoding.", correctOutput, output);
}
@Test
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
ADFGX cipher = new ADFGX(false, false, false);
//Test lowercase decoding
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
String squareKeyword = "SquareKeyword";
String keyword = "keyword";
String correctOutput = "MESSAGETOENCODE";
String output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed secure lowercase decoding.", correctOutput, output);
//Test uppercase decoding
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed secure uppercase decoding.", correctOutput, output);
//Test whitespace decoding
inputString = "aagagadfagaxxd axdx adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed secure whitespace decoding.", correctOutput, output);
//Test symbol decoding
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed secure symbol decoding.", correctOutput, output);
//Test mixed case, whitespace, and symbol decoding
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
squareKeyword = "SquareKeyword";
keyword = "keyword";
correctOutput = "MESSAGETOENCODE";
output = cipher.decode(squareKeyword, keyword, inputString);
assertEquals("ADFGX failed secure mixed case, whitesapce, and symbol decoding.", correctOutput, output);
}
}