Replaced generic exceptions with custom exceptions
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidBaseException.java
|
||||||
|
//Mattrixwv
|
||||||
|
// Created: 01-09-22
|
||||||
|
//Modified: 01-09-22
|
||||||
|
package com.mattrixwv.CipherStreamJava.exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
public class InvalidBaseException extends Exception{
|
||||||
|
public InvalidBaseException(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
public InvalidBaseException(String message){
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
public InvalidBaseException(Throwable error){
|
||||||
|
super(error);
|
||||||
|
}
|
||||||
|
public InvalidBaseException(String message, Throwable error){
|
||||||
|
super(message, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidInputException.java
|
||||||
|
//Mattrixwv
|
||||||
|
// Created: 01-09-22
|
||||||
|
//Modified: 01-09-22
|
||||||
|
package com.mattrixwv.CipherStreamJava.exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
public class InvalidInputException extends Exception{
|
||||||
|
public InvalidInputException(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
public InvalidInputException(String message){
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
public InvalidInputException(Throwable error){
|
||||||
|
super(error);
|
||||||
|
}
|
||||||
|
public InvalidInputException(String message, Throwable error){
|
||||||
|
super(message, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidKeywordException.java
|
||||||
|
//Mattrixwv
|
||||||
|
// Created: 01-09-22
|
||||||
|
//Modified: 01-09-22
|
||||||
|
package com.mattrixwv.CipherStreamJava.exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
public class InvalidKeywordException extends Exception{
|
||||||
|
public InvalidKeywordException(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
public InvalidKeywordException(String message){
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
public InvalidKeywordException(Throwable error){
|
||||||
|
super(error);
|
||||||
|
}
|
||||||
|
public InvalidKeywordException(String message, Throwable error){
|
||||||
|
super(message, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,6 +49,7 @@ public class Atbash{
|
|||||||
if(Character.isUpperCase(currentChar)){
|
if(Character.isUpperCase(currentChar)){
|
||||||
letterBase = 'A';
|
letterBase = 'A';
|
||||||
}
|
}
|
||||||
|
//TODO: Test and see if there is a more efficient way to do this
|
||||||
output.append((char)(currentChar + 25 - (2 * (currentChar - letterBase))));
|
output.append((char)(currentChar + 25 - (2 * (currentChar - letterBase))));
|
||||||
}
|
}
|
||||||
//Keep any punctuatio/whitespace the way it is
|
//Keep any punctuatio/whitespace the way it is
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
//Modified: 01-04-22
|
//Modified: 01-04-22
|
||||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||||
|
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||||
|
|
||||||
public class Autokey extends Vigenere{
|
public class Autokey extends Vigenere{
|
||||||
//Special rules for setting the strings for encoding
|
//Special rules for setting the strings for encoding
|
||||||
private void encodeSet(String key, String input) throws Exception{
|
private void encodeSet(String key, String input) throws InvalidKeywordException{
|
||||||
//Set the input
|
//Set the input
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
|
|
||||||
@@ -28,7 +30,7 @@ public class Autokey extends Vigenere{
|
|||||||
setOffset();
|
setOffset();
|
||||||
}
|
}
|
||||||
//Setting the strings for decoding
|
//Setting the strings for decoding
|
||||||
private void decodeSet(String key, String input) throws Exception{
|
private void decodeSet(String key, String input) throws InvalidKeywordException{
|
||||||
//Remove all unneccessary elements from the key
|
//Remove all unneccessary elements from the key
|
||||||
setKeyword(key);
|
setKeyword(key);
|
||||||
//Remove all unneccessary elements from the input
|
//Remove all unneccessary elements from the input
|
||||||
@@ -36,7 +38,7 @@ public class Autokey extends Vigenere{
|
|||||||
setInputString(input);
|
setInputString(input);
|
||||||
}
|
}
|
||||||
//Decodes the inputString
|
//Decodes the inputString
|
||||||
protected String decode() throws Exception{
|
protected String decode() throws InvalidKeywordException{
|
||||||
//Decode what the key will allow, add that to the key and continue
|
//Decode what the key will allow, add that to the key and continue
|
||||||
StringBuilder currentOutput = new StringBuilder();
|
StringBuilder currentOutput = new StringBuilder();
|
||||||
StringBuilder fullOutput = new StringBuilder();
|
StringBuilder fullOutput = new StringBuilder();
|
||||||
@@ -89,13 +91,13 @@ public class Autokey extends Vigenere{
|
|||||||
super(leaveCapitals, leaveWhitespace, leaveSymbols);
|
super(leaveCapitals, leaveWhitespace, leaveSymbols);
|
||||||
}
|
}
|
||||||
//Encodes inputString using the Autokey cipher
|
//Encodes inputString using the Autokey cipher
|
||||||
public String encode(String key, String input) throws Exception{
|
public String encode(String key, String input) throws InvalidKeywordException{
|
||||||
reset();
|
reset();
|
||||||
encodeSet(key, input);
|
encodeSet(key, input);
|
||||||
return encode();
|
return encode();
|
||||||
}
|
}
|
||||||
//Decodes inputString using the Autokey cipher
|
//Decodes inputString using the Autokey cipher
|
||||||
public String decode(String key, String input) throws Exception{
|
public String decode(String key, String input) throws InvalidKeywordException{
|
||||||
reset();
|
reset();
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
decodeSet(key, input);
|
decodeSet(key, input);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
|||||||
|
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||||
|
|
||||||
|
|
||||||
@@ -30,10 +31,9 @@ public class BaseX{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Sets the numeric base
|
//Sets the numeric base
|
||||||
private void setBase(int base) throws Exception{
|
private void setBase(int base) throws InvalidBaseException{
|
||||||
if(base <= 0){
|
if(base <= 0){
|
||||||
//TODO: Change this to a custom exception. InvalidParameter?
|
throw new InvalidBaseException("Base cannot be a negative number");
|
||||||
throw new Exception("Base cannot be a negative number");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.base = base;
|
this.base = base;
|
||||||
@@ -79,11 +79,11 @@ public class BaseX{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Constructor
|
//Constructor
|
||||||
public BaseX() throws Exception{
|
public BaseX() throws InvalidBaseException{
|
||||||
reset();
|
reset();
|
||||||
setBase(2);
|
setBase(2);
|
||||||
}
|
}
|
||||||
public BaseX(int base) throws Exception{
|
public BaseX(int base) throws InvalidBaseException{
|
||||||
reset();
|
reset();
|
||||||
setBase(base);
|
setBase(base);
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ public class BaseX{
|
|||||||
setInputStringEncode(inputString);
|
setInputStringEncode(inputString);
|
||||||
return encode();
|
return encode();
|
||||||
}
|
}
|
||||||
public String encode(int base, String inputString) throws Exception{
|
public String encode(int base, String inputString) throws InvalidBaseException{
|
||||||
reset();
|
reset();
|
||||||
setBase(base);
|
setBase(base);
|
||||||
setInputStringEncode(inputString);
|
setInputStringEncode(inputString);
|
||||||
@@ -117,7 +117,7 @@ public class BaseX{
|
|||||||
setInputStringDecode(inputString);
|
setInputStringDecode(inputString);
|
||||||
return decode();
|
return decode();
|
||||||
}
|
}
|
||||||
public String decode(int base, String inputString) throws Exception{
|
public String decode(int base, String inputString) throws InvalidBaseException, InvalidCharacterException{
|
||||||
reset();
|
reset();
|
||||||
setBase(base);
|
setBase(base);
|
||||||
setInputStringDecode(inputString);
|
setInputStringDecode(inputString);
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
//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-04-22
|
//Modified: 01-09-22
|
||||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||||
|
|
||||||
|
|
||||||
public class Vigenere{
|
public class Vigenere{
|
||||||
protected String inputString; //This is the string that needs encoded/decoded
|
protected String inputString; //This is the string that needs encoded/decoded
|
||||||
@@ -42,7 +44,7 @@ public class Vigenere{
|
|||||||
this.inputString = inputString;
|
this.inputString = inputString;
|
||||||
}
|
}
|
||||||
//Sets keyword
|
//Sets keyword
|
||||||
protected void setKeyword(String key) throws Exception{
|
protected void setKeyword(String key) throws InvalidKeywordException{
|
||||||
//Convert all letters to uppercase
|
//Convert all letters to uppercase
|
||||||
key = key.toUpperCase();
|
key = key.toUpperCase();
|
||||||
//Remove all characters except capital letters
|
//Remove all characters except capital letters
|
||||||
@@ -55,7 +57,7 @@ public class Vigenere{
|
|||||||
setOffset();
|
setOffset();
|
||||||
//If after all the eliminating of unusable characters the keyword is empty throw an exception
|
//If after all the eliminating of unusable characters the keyword is empty throw an exception
|
||||||
if(keyword == ""){
|
if(keyword == ""){
|
||||||
throw new Exception("The keyword cannot be empty");
|
throw new InvalidKeywordException("The keyword cannot be empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Encodes inputString and stores the result in outputString
|
//Encodes inputString and stores the result in outputString
|
||||||
@@ -93,7 +95,7 @@ public class Vigenere{
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
//Decodes inputString and stores the result in outputString
|
//Decodes inputString and stores the result in outputString
|
||||||
protected String decode() throws Exception{
|
protected String decode() throws InvalidKeywordException{
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
//Step through every character in the inputString and advance it the correct amount, according to offset
|
//Step through every character in the inputString and advance it the correct amount, according to offset
|
||||||
@@ -158,14 +160,14 @@ public class Vigenere{
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
//Encodes input using key and returns the result
|
//Encodes input using key and returns the result
|
||||||
public String encode(String key, String input) throws Exception{
|
public String encode(String key, String input) throws InvalidKeywordException{
|
||||||
reset();
|
reset();
|
||||||
setKeyword(key);
|
setKeyword(key);
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
return encode();
|
return encode();
|
||||||
}
|
}
|
||||||
//Decodes input using key and returns the result
|
//Decodes input using key and returns the result
|
||||||
public String decode(String key, String input) throws Exception{
|
public String decode(String key, String input) throws InvalidKeywordException{
|
||||||
reset();
|
reset();
|
||||||
setKeyword(key);
|
setKeyword(key);
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
@@ -173,7 +175,9 @@ public class Vigenere{
|
|||||||
}
|
}
|
||||||
//Makes sure all of the variables are empty
|
//Makes sure all of the variables are empty
|
||||||
public void reset(){
|
public void reset(){
|
||||||
inputString = outputString = keyword = "";
|
inputString = "";
|
||||||
|
outputString = "";
|
||||||
|
keyword = "";
|
||||||
offset.clear();
|
offset.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
//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-04-22
|
//Modified: 01-09-22
|
||||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||||
|
|
||||||
|
|
||||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||||
|
|
||||||
|
|
||||||
public class Playfair{
|
public class Playfair{
|
||||||
@@ -175,7 +176,7 @@ public class Playfair{
|
|||||||
createGrid();
|
createGrid();
|
||||||
}
|
}
|
||||||
//Returns the location of the given character in the grid
|
//Returns the location of the given character in the grid
|
||||||
private CharLocation findChar(char letter) throws Exception{
|
private CharLocation findChar(char letter) throws InvalidInputException{
|
||||||
for(int row = 0;row < grid.length;++row){
|
for(int row = 0;row < grid.length;++row){
|
||||||
for(int col = 0;col < grid[row].length;++col){
|
for(int col = 0;col < grid[row].length;++col){
|
||||||
if(grid[row][col] == letter){
|
if(grid[row][col] == letter){
|
||||||
@@ -184,7 +185,7 @@ public class Playfair{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//If it was not found something went wrong
|
//If it was not found something went wrong
|
||||||
throw new Exception("That character was not found in the grid. ERROR");
|
throw new InvalidInputException("The character '" + letter + "' was not found in the grid");
|
||||||
}
|
}
|
||||||
//Returns the location in the grid of x and y, adjusting for out of bounds
|
//Returns the location in the grid of x and y, adjusting for out of bounds
|
||||||
private char getGridChar(int x, int y){
|
private char getGridChar(int x, int y){
|
||||||
@@ -214,7 +215,7 @@ public class Playfair{
|
|||||||
outputString = fullOutput.toString();
|
outputString = fullOutput.toString();
|
||||||
}
|
}
|
||||||
//Encodes inputString using the Playfair cipher and stores the result in outputString
|
//Encodes inputString using the Playfair cipher and stores the result in outputString
|
||||||
private String encode() throws Exception{
|
private String encode() throws InvalidInputException{
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
int inputCnt = 0;
|
int inputCnt = 0;
|
||||||
String cleanString = getPreparedInputString();
|
String cleanString = getPreparedInputString();
|
||||||
@@ -253,7 +254,7 @@ public class Playfair{
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
//Decodes inputString using the Playfair cipher and stores the result in outputString
|
//Decodes inputString using the Playfair cipher and stores the result in outputString
|
||||||
private String decode() throws Exception{
|
private String decode() throws InvalidInputException{
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
int inputCnt = 0;
|
int inputCnt = 0;
|
||||||
String cleanString = getPreparedInputString();
|
String cleanString = getPreparedInputString();
|
||||||
@@ -320,14 +321,14 @@ public class Playfair{
|
|||||||
setDoubled(doubled);
|
setDoubled(doubled);
|
||||||
}
|
}
|
||||||
//Sets the keyword and inputString and encodes the message
|
//Sets the keyword and inputString and encodes the message
|
||||||
public String encode(String keyword, String input) throws InvalidCharacterException, Exception{
|
public String encode(String keyword, String input) throws InvalidCharacterException, InvalidInputException{
|
||||||
reset();
|
reset();
|
||||||
setKeyword(keyword);
|
setKeyword(keyword);
|
||||||
setInputString(input, true);
|
setInputString(input, true);
|
||||||
return encode();
|
return encode();
|
||||||
}
|
}
|
||||||
//Sets the keyword and inputString and decodes the message
|
//Sets the keyword and inputString and decodes the message
|
||||||
public String decode(String keyword, String input) throws InvalidCharacterException, Exception{
|
public String decode(String keyword, String input) throws InvalidCharacterException, InvalidInputException{
|
||||||
reset();
|
reset();
|
||||||
setKeyword(keyword);
|
setKeyword(keyword);
|
||||||
setInputString(input, false);
|
setInputString(input, false);
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/PolybiusSquare.java
|
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/PolybiusSquare.java
|
||||||
//Mattrixwv
|
//Mattrixwv
|
||||||
// Created: 01-04-22
|
// Created: 01-04-22
|
||||||
//Modified: 01-04-22
|
//Modified: 01-09-22
|
||||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||||
|
|
||||||
|
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||||
|
|
||||||
|
|
||||||
public class PolybiusSquare{
|
public class PolybiusSquare{
|
||||||
@@ -145,7 +146,7 @@ public class PolybiusSquare{
|
|||||||
createGrid();
|
createGrid();
|
||||||
}
|
}
|
||||||
//Returns the location of the given charcter in the grid
|
//Returns the location of the given charcter in the grid
|
||||||
public CharLocation findChar(char letter) throws Exception{
|
public CharLocation findChar(char letter) throws InvalidInputException{
|
||||||
for(int row = 0;row < grid.length;++row){
|
for(int row = 0;row < grid.length;++row){
|
||||||
for(int col = 0;col < grid[row].length;++col){
|
for(int col = 0;col < grid[row].length;++col){
|
||||||
if(grid[row][col] == letter){
|
if(grid[row][col] == letter){
|
||||||
@@ -154,7 +155,7 @@ public class PolybiusSquare{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//If it was not found something went wrong
|
//If it was not found something went wrong
|
||||||
throw new Exception("That character was not found in the grid. ERROR");
|
throw new InvalidInputException("The character '" + letter + "' was not found in the grid");
|
||||||
}
|
}
|
||||||
//Adds characters that aren't letters to the output
|
//Adds characters that aren't letters to the output
|
||||||
public void addCharactersToCleanStringEncode(String cleanString){
|
public void addCharactersToCleanStringEncode(String cleanString){
|
||||||
@@ -190,7 +191,7 @@ public class PolybiusSquare{
|
|||||||
outputString = fullOutput.toString();
|
outputString = fullOutput.toString();
|
||||||
}
|
}
|
||||||
//Encodes inputString using the Playfair cipher and stores the result in outputString
|
//Encodes inputString using the Playfair cipher and stores the result in outputString
|
||||||
private String encode() throws Exception{
|
private String encode() throws InvalidInputException{
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
String cleanString = getPreparedInputStringEncoding();
|
String cleanString = getPreparedInputStringEncoding();
|
||||||
for(int cnt = 0;cnt < cleanString.length();++cnt){
|
for(int cnt = 0;cnt < cleanString.length();++cnt){
|
||||||
@@ -256,10 +257,10 @@ public class PolybiusSquare{
|
|||||||
this.leaveSymbols = leaveSymbols;
|
this.leaveSymbols = leaveSymbols;
|
||||||
}
|
}
|
||||||
//Sets the keyword and inputString and encodes the message
|
//Sets the keyword and inputString and encodes the message
|
||||||
public String encode(String inputString) throws InvalidCharacterException, Exception{
|
public String encode(String inputString) throws InvalidCharacterException, InvalidInputException{
|
||||||
return encode("", inputString);
|
return encode("", inputString);
|
||||||
}
|
}
|
||||||
public String encode(String keyword, String inputString) throws InvalidCharacterException, Exception{
|
public String encode(String keyword, String inputString) throws InvalidCharacterException, InvalidInputException{
|
||||||
reset();
|
reset();
|
||||||
setKeyword(keyword);
|
setKeyword(keyword);
|
||||||
setInputStringEncoding(inputString);
|
setInputStringEncoding(inputString);
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestAutokey.java
|
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestAutokey.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-26-21
|
// Created: 07-26-21
|
||||||
//Modified: 01-04-22
|
//Modified: 01-09-22
|
||||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class TestAutokey{
|
public class TestAutokey{
|
||||||
@Test
|
@Test
|
||||||
public void testDecode() throws Exception{
|
public void testDecode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(true, true, true);
|
Autokey cipher = new Autokey(true, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -59,7 +61,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceDecode() throws Exception{
|
public void testNoWhitespaceDecode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(true, false, true);
|
Autokey cipher = new Autokey(true, false, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -106,7 +108,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalDecode() throws Exception{
|
public void testNoCapitalDecode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(false, true, true);
|
Autokey cipher = new Autokey(false, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -153,7 +155,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymbolDecode() throws Exception{
|
public void testNoSymbolDecode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(true, true, false);
|
Autokey cipher = new Autokey(true, true, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -200,7 +202,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalWhitespaceSymbolDecode() throws Exception{
|
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(false, false, false);
|
Autokey cipher = new Autokey(false, false, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -249,7 +251,7 @@ public class TestAutokey{
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncode() throws Exception{
|
public void testEncode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(true, true, true);
|
Autokey cipher = new Autokey(true, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -296,7 +298,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceEncode() throws Exception{
|
public void testNoWhitespaceEncode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(true, false, true);
|
Autokey cipher = new Autokey(true, false, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -343,7 +345,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalEncode() throws Exception{
|
public void testNoCapitalEncode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(false, true, true);
|
Autokey cipher = new Autokey(false, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -390,7 +392,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymbolEncode() throws Exception{
|
public void testNoSymbolEncode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(true, true, false);
|
Autokey cipher = new Autokey(true, true, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -437,7 +439,7 @@ public class TestAutokey{
|
|||||||
assertEquals("Autokey failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Autokey failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalWhitespaceSymbolEncode() throws Exception{
|
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey(false, false, false);
|
Autokey cipher = new Autokey(false, false, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -486,7 +488,7 @@ public class TestAutokey{
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeyword() throws Exception{
|
public void testKeyword() throws InvalidKeywordException{
|
||||||
Autokey cipher = new Autokey();
|
Autokey cipher = new Autokey();
|
||||||
|
|
||||||
//Test keyword with whitespace
|
//Test keyword with whitespace
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaseX.java
|
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaseX.java
|
||||||
//Mattrixwv
|
//Mattrixwv
|
||||||
// Created: 01-08-22
|
// Created: 01-08-22
|
||||||
//Modified: 01-08-22
|
//Modified: 01-09-22
|
||||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -14,7 +15,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
public class TestBaseX{
|
public class TestBaseX{
|
||||||
@Test
|
@Test
|
||||||
public void testBinaryDecode() throws InvalidCharacterException, Exception{
|
public void testBinaryDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||||
BaseX cipher = new BaseX();
|
BaseX cipher = new BaseX();
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -47,7 +48,7 @@ public class TestBaseX{
|
|||||||
assertEquals("Binary failed binary mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
assertEquals("Binary failed binary mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testOctalDecode() throws InvalidCharacterException, Exception{
|
public void testOctalDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||||
BaseX cipher = new BaseX(8);
|
BaseX cipher = new BaseX(8);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -80,7 +81,7 @@ public class TestBaseX{
|
|||||||
assertEquals("Binary failed octal mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
assertEquals("Binary failed octal mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testDecimalDecode() throws InvalidCharacterException, Exception{
|
public void testDecimalDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||||
BaseX cipher = new BaseX(10);
|
BaseX cipher = new BaseX(10);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -113,7 +114,7 @@ public class TestBaseX{
|
|||||||
assertEquals("Binary failed decimal mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
assertEquals("Binary failed decimal mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testHexDecode() throws InvalidCharacterException, Exception{
|
public void testHexDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||||
BaseX cipher = new BaseX(16);
|
BaseX cipher = new BaseX(16);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -146,7 +147,7 @@ public class TestBaseX{
|
|||||||
assertEquals("Binary failed hex mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
assertEquals("Binary failed hex mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testBinaryEncode() throws Exception{
|
public void testBinaryEncode() throws InvalidBaseException{
|
||||||
BaseX cipher = new BaseX();
|
BaseX cipher = new BaseX();
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -179,7 +180,7 @@ public class TestBaseX{
|
|||||||
assertEquals("Binary failed binary mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
assertEquals("Binary failed binary mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testOctalEncode() throws Exception{
|
public void testOctalEncode() throws InvalidBaseException{
|
||||||
BaseX cipher = new BaseX(8);
|
BaseX cipher = new BaseX(8);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -212,7 +213,7 @@ public class TestBaseX{
|
|||||||
assertEquals("Binary failed octal mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
assertEquals("Binary failed octal mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testDecimalEncode() throws Exception{
|
public void testDecimalEncode() throws InvalidBaseException{
|
||||||
BaseX cipher = new BaseX(10);
|
BaseX cipher = new BaseX(10);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -245,7 +246,7 @@ public class TestBaseX{
|
|||||||
assertEquals("Binary failed decimal mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
assertEquals("Binary failed decimal mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testHexEncode() throws Exception{
|
public void testHexEncode() throws InvalidBaseException{
|
||||||
BaseX cipher = new BaseX(16);
|
BaseX cipher = new BaseX(16);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestVigenere.java
|
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestVigenere.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-25-21
|
// Created: 07-25-21
|
||||||
//Modified: 01-04-22
|
//Modified: 01-09-22
|
||||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class TestVigenere{
|
public class TestVigenere{
|
||||||
@Test
|
@Test
|
||||||
public void testDecode() throws Exception{
|
public void testDecode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(true, true, true);
|
Vigenere cipher = new Vigenere(true, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -59,7 +61,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceDecode() throws Exception{
|
public void testNoWhitespaceDecode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(true, false, true);
|
Vigenere cipher = new Vigenere(true, false, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -106,7 +108,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalDecode() throws Exception{
|
public void testNoCapitalDecode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(false, true, true);
|
Vigenere cipher = new Vigenere(false, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -153,7 +155,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymbolDecode() throws Exception{
|
public void testNoSymbolDecode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(true, true, false);
|
Vigenere cipher = new Vigenere(true, true, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -200,7 +202,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalWhitespaceSymbolDecode() throws Exception{
|
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(false, false, false);
|
Vigenere cipher = new Vigenere(false, false, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -249,7 +251,7 @@ public class TestVigenere{
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncode() throws Exception{
|
public void testEncode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(true, true, true);
|
Vigenere cipher = new Vigenere(true, true, true);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -296,7 +298,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceEncode() throws Exception{
|
public void testNoWhitespaceEncode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(true, false, true);
|
Vigenere cipher = new Vigenere(true, false, true);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -343,7 +345,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalEncode() throws Exception{
|
public void testNoCapitalEncode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(false, true, true);
|
Vigenere cipher = new Vigenere(false, true, true);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -390,7 +392,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymbolEncode() throws Exception{
|
public void testNoSymbolEncode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(true, true, false);
|
Vigenere cipher = new Vigenere(true, true, false);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -437,7 +439,7 @@ public class TestVigenere{
|
|||||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalWhitespaceSymbolEncode() throws Exception{
|
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere(false, false, false);
|
Vigenere cipher = new Vigenere(false, false, false);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -486,7 +488,7 @@ public class TestVigenere{
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeyword() throws Exception{
|
public void testKeyword() throws InvalidKeywordException{
|
||||||
Vigenere cipher = new Vigenere();
|
Vigenere cipher = new Vigenere();
|
||||||
|
|
||||||
//Test keyword with whitespace
|
//Test keyword with whitespace
|
||||||
|
|||||||
@@ -8,13 +8,14 @@ package com.mattrixwv.CipherStreamJava.polySubstitution;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class TestPlayfair{
|
public class TestPlayfair{
|
||||||
@Test
|
@Test
|
||||||
public void testDecode() throws InvalidCharacterException, Exception{
|
public void testDecode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(true, true, true);
|
Playfair cipher = new Playfair(true, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -64,7 +65,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceDecode() throws InvalidCharacterException, Exception{
|
public void testNoWhitespaceDecode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(true, false, true);
|
Playfair cipher = new Playfair(true, false, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -114,7 +115,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalDecode() throws InvalidCharacterException, Exception{
|
public void testNoCapitalDecode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(false, true, true);
|
Playfair cipher = new Playfair(false, true, true);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -164,7 +165,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymbolDecode() throws InvalidCharacterException, Exception{
|
public void testNoSymbolDecode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(true, true, false);
|
Playfair cipher = new Playfair(true, true, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -214,7 +215,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidCharacterException, Exception{
|
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(false, false, false);
|
Playfair cipher = new Playfair(false, false, false);
|
||||||
|
|
||||||
//Test lowercase decoding
|
//Test lowercase decoding
|
||||||
@@ -264,7 +265,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed secure mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed secure mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testEncode() throws InvalidCharacterException, Exception{
|
public void testEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(true, true, true);
|
Playfair cipher = new Playfair(true, true, true);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -314,7 +315,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, Exception{
|
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(true, false, true);
|
Playfair cipher = new Playfair(true, false, true);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -364,7 +365,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed no whitespace mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed no whitespace mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalEncode() throws InvalidCharacterException, Exception{
|
public void testNoCapitalEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(false, true, true);
|
Playfair cipher = new Playfair(false, true, true);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -414,7 +415,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed no capital mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed no capital mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymbolEncode() throws InvalidCharacterException, Exception{
|
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(true, true, false);
|
Playfair cipher = new Playfair(true, true, false);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
@@ -464,7 +465,7 @@ public class TestPlayfair{
|
|||||||
assertEquals("Playfair failed no symbol mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("Playfair failed no symbol mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidCharacterException, Exception{
|
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
Playfair cipher = new Playfair(false, false, false);
|
Playfair cipher = new Playfair(false, false, false);
|
||||||
|
|
||||||
//Test lowercase encoding
|
//Test lowercase encoding
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/TestPolybiusSquare.java
|
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/TestPolybiusSquare.java
|
||||||
//Mattrixwv
|
//Mattrixwv
|
||||||
// Created: 01-04-22
|
// Created: 01-04-22
|
||||||
//Modified: 01-04-22
|
//Modified: 01-09-22
|
||||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||||
|
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ public class TestPolybiusSquare{
|
|||||||
assertEquals("PolybiusSquare failed secure whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
assertEquals("PolybiusSquare failed secure whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testEncode() throws InvalidCharacterException, Exception{
|
public void testEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
PolybiusSquare cipher = new PolybiusSquare(true, true);
|
PolybiusSquare cipher = new PolybiusSquare(true, true);
|
||||||
|
|
||||||
//Test simple encoding
|
//Test simple encoding
|
||||||
@@ -204,7 +205,7 @@ public class TestPolybiusSquare{
|
|||||||
assertEquals("PolybiusSquare failed whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("PolybiusSquare failed whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, Exception{
|
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
PolybiusSquare cipher = new PolybiusSquare(false, true);
|
PolybiusSquare cipher = new PolybiusSquare(false, true);
|
||||||
|
|
||||||
//Test simple encoding
|
//Test simple encoding
|
||||||
@@ -242,7 +243,7 @@ public class TestPolybiusSquare{
|
|||||||
assertEquals("PolybiusSquare failed no whitespace whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("PolybiusSquare failed no whitespace whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymbolEncode() throws InvalidCharacterException, Exception{
|
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
PolybiusSquare cipher = new PolybiusSquare(true, false);
|
PolybiusSquare cipher = new PolybiusSquare(true, false);
|
||||||
|
|
||||||
//Test simple encoding
|
//Test simple encoding
|
||||||
@@ -280,7 +281,7 @@ public class TestPolybiusSquare{
|
|||||||
assertEquals("PolybiusSquare failed no symbol whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
assertEquals("PolybiusSquare failed no symbol whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testNoWhitespaceSymbolEncode() throws InvalidCharacterException, Exception{
|
public void testNoWhitespaceSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||||
PolybiusSquare cipher = new PolybiusSquare(false, false);
|
PolybiusSquare cipher = new PolybiusSquare(false, false);
|
||||||
|
|
||||||
//Test simple encoding
|
//Test simple encoding
|
||||||
|
|||||||
Reference in New Issue
Block a user