Fixed sonarqube findings
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>mattrixwv</groupId>
|
||||
<artifactId>CipherStreamJava</artifactId>
|
||||
<artifactId>cipher-stream-java</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>CipherStreamJava</name>
|
||||
@@ -13,8 +13,9 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>18</maven.compiler.source>
|
||||
<maven.compiler.target>18</maven.compiler.target>
|
||||
<sonar.java.source>18</sonar.java.source>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -27,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mattrixwv</groupId>
|
||||
<artifactId>matrix</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGVX.java
|
||||
//Mattrixwv
|
||||
// Created: 01-26-22
|
||||
//Modified: 02-17-22
|
||||
package com.mattrixwv.CipherStreamJava.combination;
|
||||
//Modified: 07-03-22
|
||||
package com.mattrixwv.cipherstream.combination;
|
||||
|
||||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
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;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.polysubstitution.Columnar;
|
||||
import com.mattrixwv.cipherstream.polysubstitution.PolybiusSquare;
|
||||
|
||||
|
||||
public class ADFGVX{
|
||||
@@ -221,7 +221,7 @@ public class ADFGVX{
|
||||
//Encode the input with polybius
|
||||
String polybiusOutput = largePolybiusSquare.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", "V").replaceAll("6", "X");
|
||||
polybiusOutput = polybiusOutput.replace("1", "A").replace("2", "D").replace("3", "F").replace("4", "G").replace("5", "V").replace("6", "X");
|
||||
|
||||
//Encode polybius's output with columnar
|
||||
String columnarOutput = columnar.encode(keyword, polybiusOutput);
|
||||
@@ -237,7 +237,7 @@ public class ADFGVX{
|
||||
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("V", "5").replaceAll("X", "6");
|
||||
columnarOutput = columnarOutput.replace("A", "1").replace("D", "2").replace("F", "3").replace("G", "4").replace("V", "5").replace("X", "6");
|
||||
//Decode with polybius
|
||||
String polybiusOutput = largePolybiusSquare.decode(squareKeyword, columnarOutput);
|
||||
outputString = polybiusOutput;
|
||||
@@ -1,15 +1,15 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGX.java
|
||||
//Mattrixwv
|
||||
// Created: 01-25-22
|
||||
//Modified: 02-23-22
|
||||
package com.mattrixwv.CipherStreamJava.combination;
|
||||
//Modified: 07-03-22
|
||||
package com.mattrixwv.cipherstream.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;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.polysubstitution.Columnar;
|
||||
import com.mattrixwv.cipherstream.polysubstitution.PolybiusSquare;
|
||||
|
||||
|
||||
public class ADFGX{
|
||||
@@ -106,7 +106,7 @@ public class ADFGX{
|
||||
String polybiusOutput = polybiusSquare.encode(squareKeyword, inputString);
|
||||
squareKeyword = polybiusSquare.getKeyword();
|
||||
//Change polybius to use the correct symbols
|
||||
polybiusOutput = polybiusOutput.replaceAll("1", "A").replaceAll("2", "D").replaceAll("3", "F").replaceAll("4", "G").replaceAll("5", "X");
|
||||
polybiusOutput = polybiusOutput.replace("1", "A").replace("2", "D").replace("3", "F").replace("4", "G").replace("5", "X");
|
||||
|
||||
//Encode polybius's output with columnar
|
||||
String columnarOutput = columnar.encode(keyword, polybiusOutput);
|
||||
@@ -123,7 +123,7 @@ public class ADFGX{
|
||||
keyword = columnar.getKeyword();
|
||||
|
||||
//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");
|
||||
columnarOutput = columnarOutput.replace("A", "1").replace("D", "2").replace("F", "3").replace("G", "4").replace("X", "5");
|
||||
//Decode with polybius
|
||||
String polybiusOutput = polybiusSquare.decode(squareKeyword, columnarOutput);
|
||||
squareKeyword = polybiusSquare.getKeyword();
|
||||
@@ -2,10 +2,10 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-09-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.exceptions;
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
public class InvalidBaseException extends Exception{
|
||||
public class InvalidBaseException extends RuntimeException{
|
||||
public InvalidBaseException(){
|
||||
super();
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-04-22
|
||||
//Modified: 01-04-22
|
||||
package com.mattrixwv.CipherStreamJava.exceptions;
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
public class InvalidCharacterException extends Exception{
|
||||
public class InvalidCharacterException extends RuntimeException{
|
||||
public InvalidCharacterException(){
|
||||
super();
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-09-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.exceptions;
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
public class InvalidInputException extends Exception{
|
||||
public class InvalidInputException extends RuntimeException{
|
||||
public InvalidInputException(){
|
||||
super();
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-09-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.exceptions;
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
public class InvalidKeywordException extends Exception{
|
||||
public class InvalidKeywordException extends RuntimeException{
|
||||
public InvalidKeywordException(){
|
||||
super();
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-26-22
|
||||
//Modified: 02-17-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
import mattrixwv.NumberAlgorithms;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
//Mattrixwv
|
||||
// Created: 07-25-21
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class Atbash{
|
||||
@@ -14,32 +14,6 @@ public class Atbash{
|
||||
private boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
private boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
private boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
//Decodes inputString and stores in outputString
|
||||
private String decode(){
|
||||
StringBuilder output = new StringBuilder();
|
||||
//Stop through every element in the inputString and shift it the correct amount
|
||||
for(int cnt = 0;cnt < inputString.length();++cnt){
|
||||
char currentChar = inputString.charAt(cnt);
|
||||
//Decode if the letter is alphabetic
|
||||
if(Character.isAlphabetic(currentChar)){
|
||||
//Use either uppercase or lowercase for the base
|
||||
//(letterbase + 25 - (currentChar - letterBase))
|
||||
if(Character.isUpperCase(currentChar)){
|
||||
output.append((char)(155 - currentChar));
|
||||
}
|
||||
else{
|
||||
output.append((char)(219 - currentChar));
|
||||
}
|
||||
}
|
||||
//Keep any punctuation/whitespace the way it is
|
||||
else{
|
||||
output.append(currentChar);
|
||||
}
|
||||
}
|
||||
|
||||
outputString = output.toString();
|
||||
return outputString;
|
||||
}
|
||||
//Encodes inputString and stores in outputString
|
||||
private String encode(){
|
||||
StringBuilder output = new StringBuilder();
|
||||
@@ -119,10 +93,7 @@ public class Atbash{
|
||||
return encode();
|
||||
}
|
||||
public String decode(String inputString) throws InvalidInputException{
|
||||
//Make sure everything is empty before you begin
|
||||
reset();
|
||||
setInputString(inputString);
|
||||
return decode();
|
||||
return encode(inputString);
|
||||
}
|
||||
public void reset(){
|
||||
inputString = outputString = "";
|
||||
@@ -1,12 +1,12 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/Autokey.java
|
||||
//Mattrixwv
|
||||
// Created: 07-25-21
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
//Modified: 07-03-22
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Autokey extends Vigenere{
|
||||
@@ -40,7 +40,8 @@ public class Autokey extends Vigenere{
|
||||
setInputString(inputString);
|
||||
}
|
||||
//Decodes the inputString
|
||||
protected String decode() throws InvalidKeywordException{
|
||||
@Override
|
||||
protected String decode(){
|
||||
//Decode what the key will allow, add that to the key and continue
|
||||
StringBuilder currentOutput = new StringBuilder();
|
||||
StringBuilder fullOutput = new StringBuilder();
|
||||
@@ -93,12 +94,14 @@ public class Autokey extends Vigenere{
|
||||
super(preserveCapitals, preserveWhitespace, preserveSymbols);
|
||||
}
|
||||
//Encodes inputString using the Autokey cipher
|
||||
@Override
|
||||
public String encode(String keyword, String inputString) throws InvalidKeywordException, InvalidInputException{
|
||||
reset();
|
||||
encodeSet(keyword, inputString);
|
||||
return encode();
|
||||
}
|
||||
//Decodes inputString using the Autokey cipher
|
||||
@Override
|
||||
public String decode(String keyword, String inputString) throws InvalidKeywordException, InvalidInputException{
|
||||
reset();
|
||||
decodeSet(keyword, inputString);
|
||||
@@ -2,17 +2,17 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-12-22
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
public class Baconian{
|
||||
private static final ArrayList<String> code = new ArrayList<String>(Arrays.asList(
|
||||
private static final ArrayList<String> code = new ArrayList<>(Arrays.asList(
|
||||
"aaaaa", "aaaab", "aaaba", "aaabb", "aabaa", "aabab", "aabba","aabbb", "abaaa", "abaaa", "abaab", "ababa", "ababb", //A-M
|
||||
"abbaa", "abbab", "abbba", "abbbb", "baaaa", "baaab", "baaba", "baabb", "baabb", "babaa", "babab", "babba", "babbb" //N-Z
|
||||
));
|
||||
@@ -63,7 +63,7 @@ public class Baconian{
|
||||
this.inputString = inputString;
|
||||
|
||||
if(this.inputString.isBlank()){
|
||||
throw new InvalidInputException("Input cannot be null");
|
||||
throw new InvalidInputException("Input cannot be empty");
|
||||
}
|
||||
}
|
||||
//Encodes the inputString and stores the result in outputString
|
||||
@@ -97,7 +97,7 @@ public class Baconian{
|
||||
int location = code.indexOf(baconianCharacter.toLowerCase());
|
||||
|
||||
//Convert the Baconian character to an ASCII character
|
||||
char ch = '\0';
|
||||
char ch;
|
||||
if(Character.isUpperCase(baconianCharacter.charAt(0))){
|
||||
ch = (char)(location + 'A');
|
||||
}
|
||||
@@ -2,14 +2,14 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-08-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
|
||||
|
||||
|
||||
public class BaseX{
|
||||
@@ -2,11 +2,11 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-23-22
|
||||
//Modified: 02-23-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Beaufort{
|
||||
@@ -2,10 +2,10 @@
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 02-17-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class Caesar{
|
||||
@@ -2,11 +2,11 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-23-22
|
||||
//Modified: 02-23-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class OneTimePad extends Vigenere{
|
||||
@@ -2,11 +2,11 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-28-22
|
||||
//Modified: 02-28-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Porta{
|
||||
@@ -78,7 +78,7 @@ public class Porta{
|
||||
private char getReplacer(int keywordCnt, char letter){
|
||||
char keyLetter = keyword.charAt(keywordCnt % keyword.length());
|
||||
int tableauColumn = (Character.toUpperCase(letter) - 'A');
|
||||
char replacer = '\0';
|
||||
char replacer;
|
||||
|
||||
switch(keyLetter){
|
||||
case 'A':
|
||||
@@ -2,11 +2,11 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-22-22
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Substitution{
|
||||
@@ -2,13 +2,14 @@
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Vigenere{
|
||||
@@ -110,7 +111,7 @@ public class Vigenere{
|
||||
return outputString;
|
||||
}
|
||||
//Decodes inputString and stores the result in outputString
|
||||
protected String decode() throws InvalidKeywordException{
|
||||
protected String decode(){
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
//Step through every character in the inputString and advance it the correct amount, according to offset
|
||||
@@ -145,14 +146,14 @@ public class Vigenere{
|
||||
|
||||
//Constructor
|
||||
public Vigenere(){
|
||||
offset = new ArrayList<Integer>();
|
||||
offset = new ArrayList<>();
|
||||
reset();
|
||||
preserveCapitals = false;
|
||||
preserveWhitespace = false;
|
||||
preserveSymbols = false;
|
||||
}
|
||||
public Vigenere(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols){
|
||||
offset = new ArrayList<Integer>();
|
||||
offset = new ArrayList<>();
|
||||
reset();
|
||||
this.preserveCapitals = preserveCapitals;
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
@@ -171,7 +172,7 @@ public class Vigenere{
|
||||
return keyword;
|
||||
}
|
||||
//Returns the current offsets (Used mostly in bug fixing)
|
||||
public ArrayList<Integer> getOffsets(){
|
||||
public List<Integer> getOffsets(){
|
||||
return offset;
|
||||
}
|
||||
//Encodes input using key and returns the result
|
||||
@@ -2,11 +2,11 @@
|
||||
//Mattrixwv
|
||||
// Created: 03-03-22
|
||||
//Modified: 03-03-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
public class Bifid{
|
||||
private String inputString; //The message that needs to be encoded/decoded
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-16-22
|
||||
//Modified: 03-03-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class Columnar{
|
||||
@@ -33,8 +33,8 @@ public class Columnar{
|
||||
//Create the grid from the keyword
|
||||
private void createGridEncode(){
|
||||
//Add the keyword to the first row in the array
|
||||
grid = new ArrayList<ArrayList<Character>>();
|
||||
grid.add(new ArrayList<Character>(Arrays.asList(keyword.chars().mapToObj(c -> (char)c).toArray(Character[]::new))));
|
||||
grid = new ArrayList<>();
|
||||
grid.add(new ArrayList<>(Arrays.asList(keyword.chars().mapToObj(c -> (char)c).toArray(Character[]::new))));
|
||||
|
||||
//Create the input that will be used for encoding
|
||||
String gridInputString = getCleanInputString();
|
||||
@@ -42,7 +42,7 @@ public class Columnar{
|
||||
//Create arrays from the inputString of keyword.size length and add them each as new rows to the grid
|
||||
//?gridRow could be changed to grid.size(), but would it be worth the extra confusion? Probably not unless I really want to min/max
|
||||
for(int gridRow = 1;(keyword.length() * gridRow) <= gridInputString.length();++gridRow){
|
||||
grid.add(new ArrayList<Character>(Arrays.asList(
|
||||
grid.add(new ArrayList<>(Arrays.asList(
|
||||
gridInputString.substring(keyword.length() * (gridRow - 1), (keyword.length() * gridRow))
|
||||
.chars().mapToObj(c->(char)c).toArray(Character[]::new)
|
||||
)));
|
||||
@@ -50,12 +50,12 @@ public class Columnar{
|
||||
}
|
||||
private void createGridDecode(){
|
||||
//Add the keyword to the first row in the array
|
||||
grid = new ArrayList<ArrayList<Character>>();
|
||||
grid = new ArrayList<>();
|
||||
StringBuilder orderedKeyword = new StringBuilder();
|
||||
for(int cnt : getKeywordAlphaLocations()){
|
||||
orderedKeyword.append(keyword.charAt(cnt));
|
||||
}
|
||||
grid.add(new ArrayList<Character>(Arrays.asList(orderedKeyword.chars().mapToObj(c -> (char)c).toArray(Character[]::new))));
|
||||
grid.add(new ArrayList<>(Arrays.asList(orderedKeyword.chars().mapToObj(c -> (char)c).toArray(Character[]::new))));
|
||||
|
||||
//Create the input that will be used for encoding
|
||||
String gridInputString = getCleanInputString();
|
||||
@@ -63,7 +63,7 @@ public class Columnar{
|
||||
//Make sure the grid has the appropritate number of rows
|
||||
int numRows = inputString.length() / keyword.length();
|
||||
while(grid.size() <= numRows){
|
||||
grid.add(new ArrayList<Character>());
|
||||
grid.add(new ArrayList<>());
|
||||
}
|
||||
//Add each character to the grid
|
||||
int rowCnt = 1;
|
||||
@@ -142,7 +142,7 @@ public class Columnar{
|
||||
if(numCharsOver > 0){
|
||||
//Get the first n of the characters in the keyword and their encoded column locations
|
||||
ArrayList<Integer> originalLocations = getKeywordOriginalLocations();
|
||||
ArrayList<Integer> longColumns = new ArrayList<Integer>();
|
||||
ArrayList<Integer> longColumns = new ArrayList<>();
|
||||
for(int cnt = 0;cnt < numCharsOver;++cnt){
|
||||
longColumns.add(originalLocations.get(cnt));
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class Columnar{
|
||||
//Creates the output string from the grid
|
||||
private void createOutputStringFromColumns(){
|
||||
//Get the current rows of any characters that you added
|
||||
ArrayList<Integer> colsAddedTo = new ArrayList<Integer>();
|
||||
ArrayList<Integer> colsAddedTo = new ArrayList<>();
|
||||
if(removePadding){
|
||||
ArrayList<Integer> cols = getKeywordOriginalLocations();
|
||||
Collections.reverse(cols);
|
||||
@@ -251,7 +251,7 @@ public class Columnar{
|
||||
charsAdded = 0;
|
||||
}
|
||||
|
||||
ArrayList<Integer> colsAddedTo = new ArrayList<Integer>();
|
||||
ArrayList<Integer> colsAddedTo = new ArrayList<>();
|
||||
if(removePadding){
|
||||
ArrayList<Integer> cols = getKeywordOriginalLocations();
|
||||
Collections.reverse(cols);
|
||||
@@ -320,7 +320,7 @@ public class Columnar{
|
||||
}
|
||||
//Returns a list of integers that represents the location of the characters of the keyword in alphabetic order
|
||||
private ArrayList<Integer> getKeywordAlphaLocations(){
|
||||
ArrayList<Integer> orderedLocations = new ArrayList<Integer>();
|
||||
ArrayList<Integer> orderedLocations = new ArrayList<>();
|
||||
//go through every letter and check it against the keyword
|
||||
for(char ch = 'A';ch <= 'Z';++ch){
|
||||
for(int cnt = 0;cnt < keyword.length();++cnt){
|
||||
@@ -338,7 +338,7 @@ public class Columnar{
|
||||
//Figure out the order the columns are in
|
||||
ArrayList<Integer> orderedLocations = getKeywordAlphaLocations();
|
||||
//Figure out what order the columns need rearanged to
|
||||
ArrayList<Integer> originalOrder = new ArrayList<Integer>();
|
||||
ArrayList<Integer> originalOrder = new ArrayList<>();
|
||||
for(int orgCnt = 0;orgCnt < orderedLocations.size();++orgCnt){
|
||||
for(int orderedCnt = 0;orderedCnt < orderedLocations.size();++orderedCnt){
|
||||
if(orderedLocations.get(orderedCnt) == orgCnt){
|
||||
@@ -353,9 +353,9 @@ public class Columnar{
|
||||
private void rearangeGrid(ArrayList<Integer> listOrder){
|
||||
//Create a new grid and make sure it is the same size as the original grid
|
||||
int numCol = grid.get(0).size();
|
||||
ArrayList<ArrayList<Character>> newGrid = new ArrayList<ArrayList<Character>>(grid.size());
|
||||
ArrayList<ArrayList<Character>> newGrid = new ArrayList<>(grid.size());
|
||||
for(int cnt = 0;cnt < grid.size();++cnt){
|
||||
newGrid.add(new ArrayList<Character>(numCol));
|
||||
newGrid.add(new ArrayList<>(numCol));
|
||||
}
|
||||
|
||||
//Step through the list order, pull out the columns, and add them to the new grid
|
||||
@@ -443,7 +443,7 @@ public class Columnar{
|
||||
inputString = "";
|
||||
outputString = "";
|
||||
keyword = "";
|
||||
grid = new ArrayList<ArrayList<Character>>();
|
||||
grid = new ArrayList<>();
|
||||
charsAdded = 0;
|
||||
}
|
||||
//Gets
|
||||
@@ -2,14 +2,14 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-31-22
|
||||
//Modified: 02-17-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.matrix.ModMatrix;
|
||||
import com.mattrixwv.matrix.exceptions.InvalidGeometryException;
|
||||
import com.mattrixwv.matrix.exceptions.InvalidScalarException;
|
||||
@@ -46,7 +46,7 @@ public class Hill{
|
||||
}
|
||||
|
||||
//Set the key
|
||||
this.key = key.clone();
|
||||
this.key = new ModMatrix(key);
|
||||
}
|
||||
private void setInputString(String inputString) throws InvalidInputException{
|
||||
//Remove anything that needs removed
|
||||
@@ -135,7 +135,7 @@ public class Hill{
|
||||
String cleanInput = getCleanInputString();
|
||||
|
||||
//Break the inputString up into lengths of numCols
|
||||
ArrayList<ModMatrix> vectors = new ArrayList<ModMatrix>();
|
||||
ArrayList<ModMatrix> vectors = new ArrayList<>();
|
||||
for(int cnt = 0;cnt < cleanInput.length();cnt += numCols){
|
||||
String subString = cleanInput.substring(cnt, cnt + numCols);
|
||||
int[] grid = new int[numCols];
|
||||
@@ -174,7 +174,7 @@ public class Hill{
|
||||
ArrayList<ModMatrix> inputVectors = getInputVectors();
|
||||
|
||||
//Multiply the key by each vector and add the result to a new vector
|
||||
ArrayList<ModMatrix> outputVectors = new ArrayList<ModMatrix>();
|
||||
ArrayList<ModMatrix> outputVectors = new ArrayList<>();
|
||||
for(ModMatrix inputVector : inputVectors){
|
||||
ModMatrix outputVector = key.multiply(inputVector);
|
||||
outputVectors.add(outputVector);
|
||||
@@ -195,7 +195,7 @@ public class Hill{
|
||||
|
||||
//Multiply the inverse of the key by each vector and add the result to a new vector
|
||||
ModMatrix inverseKey = key.inverse();
|
||||
ArrayList<ModMatrix> outputVectors = new ArrayList<ModMatrix>();
|
||||
ArrayList<ModMatrix> outputVectors = new ArrayList<>();
|
||||
for(ModMatrix inputVector : inputVectors){
|
||||
ModMatrix outputVector = inverseKey.multiply(inputVector);
|
||||
outputVectors.add(outputVector);
|
||||
@@ -2,7 +2,7 @@
|
||||
//Matthew Ellison
|
||||
// Created: 07-28-21
|
||||
//Modified: 01-16-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
public class Morse{
|
||||
@@ -2,11 +2,11 @@
|
||||
//Matthew Ellison
|
||||
// Created: 07-30-21
|
||||
//Modified: 02-17-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class Playfair{
|
||||
@@ -74,68 +74,7 @@ public class Playfair{
|
||||
|
||||
//If this is encoding parse it and clean up an problems
|
||||
if(encoding){
|
||||
//Replace characters that need replaced
|
||||
inputString = inputString.replaceAll(Character.toString(replaced), Character.toString(replacer));
|
||||
|
||||
//Check if there are any doubled characters
|
||||
StringBuilder cleanInput = new StringBuilder();
|
||||
int letterCount = 0;
|
||||
for(int cnt = 0;cnt < inputString.length();){
|
||||
//Advance until you find a letter, saving the input for inclusion
|
||||
StringBuilder prepend = new StringBuilder();
|
||||
while((cnt < inputString.length()) && !Character.isAlphabetic(inputString.charAt(cnt))){
|
||||
prepend.append(inputString.charAt(cnt++));
|
||||
}
|
||||
//If we have reached the end of the string end the loop
|
||||
if(cnt == inputString.length()){
|
||||
cleanInput.append(prepend);
|
||||
break;
|
||||
}
|
||||
//Get the next character
|
||||
char firstLetter = inputString.charAt(cnt++);
|
||||
++letterCount;
|
||||
|
||||
//Advance until you find a letter, saving the input for inclusion
|
||||
StringBuilder middle = new StringBuilder();
|
||||
while((cnt < inputString.length()) && !Character.isAlphabetic(inputString.charAt(cnt))){
|
||||
middle.append(inputString.charAt(cnt++));
|
||||
}
|
||||
char secondLetter = '\0';
|
||||
//If we have not reached the end of the string get the next character
|
||||
if(cnt != inputString.length()){
|
||||
secondLetter = inputString.charAt(cnt++);
|
||||
++letterCount;
|
||||
}
|
||||
//If the second character is the same as the first character set the pointer back and use the doubled character
|
||||
if(secondLetter == firstLetter){
|
||||
--cnt;
|
||||
secondLetter = doubled;
|
||||
}
|
||||
|
||||
//Add all of the gathered input to the cleaned up input
|
||||
cleanInput.append(prepend);
|
||||
cleanInput.append(firstLetter);
|
||||
cleanInput.append(middle);
|
||||
if(secondLetter != '\0'){
|
||||
cleanInput.append(secondLetter);
|
||||
}
|
||||
}
|
||||
|
||||
//Check if there are an odd number of characters
|
||||
if((letterCount % 2) == 1){
|
||||
int lastLetterLocation = cleanInput.length() - 1;
|
||||
while(!Character.isAlphabetic(cleanInput.charAt(lastLetterLocation))){
|
||||
--lastLetterLocation;
|
||||
}
|
||||
if(cleanInput.charAt(lastLetterLocation) == doubled){
|
||||
cleanInput.append(replacer);
|
||||
}
|
||||
else{
|
||||
cleanInput.append(doubled);
|
||||
}
|
||||
}
|
||||
|
||||
this.inputString = cleanInput.toString();
|
||||
setEncodingInputString(inputString);
|
||||
}
|
||||
//If this is decoding just add it without parsing it
|
||||
else{
|
||||
@@ -151,6 +90,70 @@ public class Playfair{
|
||||
throw new InvalidInputException("Input must have at least 1 letter");
|
||||
}
|
||||
}
|
||||
private void setEncodingInputString(String inputString){
|
||||
//Replace characters that need replaced
|
||||
inputString = inputString.replaceAll(Character.toString(replaced), Character.toString(replacer));
|
||||
|
||||
//Check if there are any doubled characters
|
||||
StringBuilder cleanInput = new StringBuilder();
|
||||
int letterCount = 0;
|
||||
for(int cnt = 0;cnt < inputString.length();){
|
||||
//Advance until you find a letter, saving the input for inclusion
|
||||
StringBuilder prepend = new StringBuilder();
|
||||
while((cnt < inputString.length()) && !Character.isAlphabetic(inputString.charAt(cnt))){
|
||||
prepend.append(inputString.charAt(cnt++));
|
||||
}
|
||||
//If we have reached the end of the string end the loop
|
||||
if(cnt == inputString.length()){
|
||||
cleanInput.append(prepend);
|
||||
break;
|
||||
}
|
||||
//Get the next character
|
||||
char firstLetter = inputString.charAt(cnt++);
|
||||
++letterCount;
|
||||
|
||||
//Advance until you find a letter, saving the input for inclusion
|
||||
StringBuilder middle = new StringBuilder();
|
||||
while((cnt < inputString.length()) && !Character.isAlphabetic(inputString.charAt(cnt))){
|
||||
middle.append(inputString.charAt(cnt++));
|
||||
}
|
||||
char secondLetter = '\0';
|
||||
//If we have not reached the end of the string get the next character
|
||||
if(cnt != inputString.length()){
|
||||
secondLetter = inputString.charAt(cnt++);
|
||||
++letterCount;
|
||||
}
|
||||
//If the second character is the same as the first character set the pointer back and use the doubled character
|
||||
if(secondLetter == firstLetter){
|
||||
--cnt;
|
||||
secondLetter = doubled;
|
||||
}
|
||||
|
||||
//Add all of the gathered input to the cleaned up input
|
||||
cleanInput.append(prepend);
|
||||
cleanInput.append(firstLetter);
|
||||
cleanInput.append(middle);
|
||||
if(secondLetter != '\0'){
|
||||
cleanInput.append(secondLetter);
|
||||
}
|
||||
}
|
||||
|
||||
//Check if there are an odd number of characters
|
||||
if((letterCount % 2) == 1){
|
||||
int lastLetterLocation = cleanInput.length() - 1;
|
||||
while(!Character.isAlphabetic(cleanInput.charAt(lastLetterLocation))){
|
||||
--lastLetterLocation;
|
||||
}
|
||||
if(cleanInput.charAt(lastLetterLocation) == doubled){
|
||||
cleanInput.append(replacer);
|
||||
}
|
||||
else{
|
||||
cleanInput.append(doubled);
|
||||
}
|
||||
}
|
||||
|
||||
this.inputString = cleanInput.toString();
|
||||
}
|
||||
//Returns the input string ready for encoding
|
||||
private String getPreparedInputString(){
|
||||
String cleanString = inputString.toUpperCase();
|
||||
@@ -2,13 +2,13 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-04-22
|
||||
//Modified: 02-17-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class PolybiusSquare{
|
||||
@@ -135,8 +135,7 @@ public class PolybiusSquare{
|
||||
return cleanString;
|
||||
}
|
||||
protected String getPreparedInputStringDecoding(){
|
||||
String cleanString = inputString.replaceAll("[^0-9]", "");
|
||||
return cleanString;
|
||||
return inputString.replaceAll("[^0-9]", "");
|
||||
}
|
||||
//Strips invalid characters from the keyword and creates the grid
|
||||
protected void setKeyword(String keyword){
|
||||
@@ -2,13 +2,13 @@
|
||||
//Mattrixwv
|
||||
// Created: 03-21-22
|
||||
//Modified: 03-22-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
|
||||
|
||||
|
||||
public class RailFence{
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 03-03-22
|
||||
//Modified: 03-03-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
|
||||
|
||||
|
||||
public class Trifid{
|
||||
@@ -194,7 +194,7 @@ public class Trifid{
|
||||
//Encodes inputString using a polybius square and stores the result in outputString
|
||||
private void encode() throws InvalidCharacterException{
|
||||
//Step through every element in the sanitized inputString encoding the letters
|
||||
ArrayList<CharLocation> locations = new ArrayList<CharLocation>();
|
||||
ArrayList<CharLocation> locations = new ArrayList<>();
|
||||
for(char ch : getCleanInputString().toCharArray()){
|
||||
//Get the location of the char in the grid
|
||||
CharLocation location = findChar(ch);
|
||||
@@ -206,9 +206,9 @@ public class Trifid{
|
||||
if(numGroups == 0){
|
||||
numGroups = 1;
|
||||
}
|
||||
ArrayList<ArrayList<CharLocation>> groups = new ArrayList<ArrayList<CharLocation>>(numGroups);
|
||||
ArrayList<ArrayList<CharLocation>> groups = new ArrayList<>(numGroups);
|
||||
for(int cnt = 0;cnt < numGroups;++cnt){
|
||||
groups.add(new ArrayList<CharLocation>());
|
||||
groups.add(new ArrayList<>());
|
||||
}
|
||||
int groupCnt = -1;
|
||||
for(int locCnt = 0;locCnt < locations.size();++locCnt){
|
||||
@@ -220,12 +220,12 @@ public class Trifid{
|
||||
}
|
||||
|
||||
//Split the coordinates into rows
|
||||
ArrayList<Integer> coordinates = new ArrayList<Integer>(locations.size() * 3);
|
||||
ArrayList<Integer> coordinates = new ArrayList<>(locations.size() * 3);
|
||||
for(ArrayList<CharLocation> group : groups){
|
||||
//Split the coordinates up into 3 rows
|
||||
ArrayList<Integer> layers = new ArrayList<Integer>(group.size());
|
||||
ArrayList<Integer> rows = new ArrayList<Integer>(group.size());
|
||||
ArrayList<Integer> cols = new ArrayList<Integer>(group.size());
|
||||
ArrayList<Integer> layers = new ArrayList<>(group.size());
|
||||
ArrayList<Integer> rows = new ArrayList<>(group.size());
|
||||
ArrayList<Integer> cols = new ArrayList<>(group.size());
|
||||
for(CharLocation loc : group){
|
||||
layers.add(loc.getZ());
|
||||
rows.add(loc.getX());
|
||||
@@ -236,7 +236,7 @@ public class Trifid{
|
||||
coordinates.addAll(cols);
|
||||
}
|
||||
//Create new locations from the rows of coordinates
|
||||
ArrayList<CharLocation> newLocations = new ArrayList<CharLocation>(locations.size());
|
||||
ArrayList<CharLocation> newLocations = new ArrayList<>(locations.size());
|
||||
for(int cnt = 0;cnt < coordinates.size();){
|
||||
int z = coordinates.get(cnt++);
|
||||
int x = coordinates.get(cnt++);
|
||||
@@ -256,7 +256,7 @@ public class Trifid{
|
||||
//Decodes inputString using a polybius square and stores the result in outputString
|
||||
private void decode() throws InvalidCharacterException{
|
||||
//Step through every element in the sanitized inputString encoding the letters
|
||||
ArrayList<CharLocation> locations = new ArrayList<CharLocation>();
|
||||
ArrayList<CharLocation> locations = new ArrayList<>();
|
||||
for(char ch : getCleanInputString().toCharArray()){
|
||||
//Get the location of the char in the grid
|
||||
CharLocation location = findChar(ch);
|
||||
@@ -268,9 +268,9 @@ public class Trifid{
|
||||
if(numGroups == 0){
|
||||
numGroups = 1;
|
||||
}
|
||||
ArrayList<ArrayList<CharLocation>> groups = new ArrayList<ArrayList<CharLocation>>(numGroups);
|
||||
ArrayList<ArrayList<CharLocation>> groups = new ArrayList<>(numGroups);
|
||||
for(int cnt = 0;cnt < numGroups;++cnt){
|
||||
groups.add(new ArrayList<CharLocation>());
|
||||
groups.add(new ArrayList<>());
|
||||
}
|
||||
int groupCnt = -1;
|
||||
for(int locCnt = 0;locCnt < locations.size();++locCnt){
|
||||
@@ -282,10 +282,10 @@ public class Trifid{
|
||||
}
|
||||
|
||||
//Split the coordinates into rows by group and create the original grid locations
|
||||
ArrayList<CharLocation> originalLocations = new ArrayList<CharLocation>(locations.size());
|
||||
ArrayList<CharLocation> originalLocations = new ArrayList<>(locations.size());
|
||||
for(ArrayList<CharLocation> group : groups){
|
||||
//Read all of the coordinates from the group out into a row
|
||||
ArrayList<Integer> coordinates = new ArrayList<Integer>(group.size() * 3);
|
||||
ArrayList<Integer> coordinates = new ArrayList<>(group.size() * 3);
|
||||
for(CharLocation loc : group){
|
||||
coordinates.add(loc.getZ());
|
||||
coordinates.add(loc.getX());
|
||||
@@ -293,7 +293,7 @@ public class Trifid{
|
||||
}
|
||||
|
||||
//Read out the coordinates into new locations
|
||||
ArrayList<CharLocation> originalGroup = new ArrayList<CharLocation>(group.size());
|
||||
ArrayList<CharLocation> originalGroup = new ArrayList<>(group.size());
|
||||
for(int cnt = 0;cnt < group.size();++cnt){
|
||||
originalGroup.add(new CharLocation(0, 0, 0));
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public class Trifid{
|
||||
return outputString;
|
||||
}
|
||||
//Decodes inputString using keyword and groupSize and returns the result
|
||||
public String decode(String keyword, String inputString) throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException, InvalidCharacterException{
|
||||
public String decode(String keyword, String inputString) throws InvalidBaseException, InvalidKeywordException, InvalidInputException, InvalidCharacterException{
|
||||
return decode(keyword, inputString.length(), inputString);
|
||||
}
|
||||
public String decode(String keyword, int groupSize, String inputString) throws InvalidBaseException, InvalidKeywordException, InvalidInputException, InvalidCharacterException{
|
||||
@@ -2,17 +2,17 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-26-22
|
||||
//Modified: 01-26-22
|
||||
package com.mattrixwv.CipherStreamJava.combination;
|
||||
package com.mattrixwv.cipherstream.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;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestADFGVX{
|
||||
@Test
|
||||
@@ -2,17 +2,17 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-25-22
|
||||
//Modified: 01-25-22
|
||||
package com.mattrixwv.CipherStreamJava.combination;
|
||||
package com.mattrixwv.cipherstream.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;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestADFGX{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-26-22
|
||||
//Modified: 01-26-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestAffine{
|
||||
@Test
|
||||
@@ -2,15 +2,15 @@
|
||||
//Mattrixwv
|
||||
// Created: 07-25-21
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestAtbash{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 07-26-21
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestAutokey{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-12-22
|
||||
//Modified: 01-12-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestBaconian{
|
||||
@Test
|
||||
@@ -2,17 +2,17 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-08-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestBaseX{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-23-22
|
||||
//Modified: 02-23-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestBeaufort{
|
||||
@Test
|
||||
@@ -2,15 +2,15 @@
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 01-04-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestCaesar{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-23-22
|
||||
//Modified: 02-23-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestOneTimePad{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-28-22
|
||||
//Modified: 02-28-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestPorta{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 02-22-22
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestSubstitution{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 07-25-21
|
||||
//Modified: 02-22-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestVigenere{
|
||||
@Test
|
||||
@@ -2,17 +2,17 @@
|
||||
//Mattrixwv
|
||||
// Created: 03-03-22
|
||||
//Modified: 03-03-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestBifid{
|
||||
@Test
|
||||
@@ -2,17 +2,17 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-16-22
|
||||
//Modified: 03-03-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestColumnar{
|
||||
@Test
|
||||
@@ -2,18 +2,18 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-31-22
|
||||
//Modified: 02-17-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestHill{
|
||||
@Test
|
||||
@@ -2,7 +2,7 @@
|
||||
//Matthew Ellison
|
||||
// Created: 07-28-21
|
||||
//Modified: 01-04-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -2,16 +2,16 @@
|
||||
//Matthew Ellison
|
||||
// Created: 07-30-21
|
||||
//Modified: 01-04-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestPlayfair{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 01-04-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestPolybiusSquare{
|
||||
@Test
|
||||
@@ -2,16 +2,16 @@
|
||||
//Mattrixwv
|
||||
// Created: 03-21-22
|
||||
//Modified: 03-22-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
|
||||
|
||||
public class TestRailFence{
|
||||
@Test
|
||||
@@ -2,18 +2,18 @@
|
||||
//Mattrixwv
|
||||
// Created: 03-03-22
|
||||
//Modified: 03-03-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
public class TestTrifid{
|
||||
@Test
|
||||
Reference in New Issue
Block a user