From b4817e8bb3331a19abf8d1f5000621512e0ed1ee Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Mon, 4 Jul 2022 01:04:06 -0400 Subject: [PATCH] Fixed sonarqube findings --- pom.xml | 9 +- .../combination/ADFGVX.java | 18 +-- .../combination/ADFGX.java | 18 +-- .../exceptions}/InvalidBaseException.java | 4 +- .../InvalidCharacterException.java | 4 +- .../exceptions}/InvalidInputException.java | 4 +- .../exceptions}/InvalidKeywordException.java | 4 +- .../monosubstitution}/Affine.java | 6 +- .../monosubstitution}/Atbash.java | 35 +---- .../monosubstitution}/Autokey.java | 13 +- .../monosubstitution}/Baconian.java | 12 +- .../monosubstitution}/BaseX.java | 8 +- .../monosubstitution}/Beaufort.java | 6 +- .../monosubstitution}/Caesar.java | 4 +- .../monosubstitution}/OneTimePad.java | 6 +- .../monosubstitution}/Porta.java | 8 +- .../monosubstitution}/Substitution.java | 6 +- .../monosubstitution}/Vigenere.java | 15 +- .../polysubstitution}/Bifid.java | 8 +- .../polysubstitution}/Columnar.java | 36 ++--- .../polysubstitution}/Hill.java | 14 +- .../polysubstitution}/Morse.java | 2 +- .../polysubstitution}/Playfair.java | 133 +++++++++--------- .../polysubstitution}/PolybiusSquare.java | 9 +- .../polysubstitution}/RailFence.java | 6 +- .../polysubstitution}/Trifid.java | 40 +++--- .../combination/TestADFGVX.java | 10 +- .../combination/TestADFGX.java | 10 +- .../monosubstitution}/TestAffine.java | 8 +- .../monosubstitution}/TestAtbash.java | 6 +- .../monosubstitution}/TestAutokey.java | 8 +- .../monosubstitution}/TestBaconian.java | 8 +- .../monosubstitution}/TestBaseX.java | 10 +- .../monosubstitution}/TestBeaufort.java | 8 +- .../monosubstitution}/TestCaesar.java | 6 +- .../monosubstitution}/TestOneTimePad.java | 8 +- .../monosubstitution}/TestPorta.java | 8 +- .../monosubstitution}/TestSubstitution.java | 8 +- .../monosubstitution}/TestVigenere.java | 8 +- .../polysubstitution}/TestBifid.java | 10 +- .../polysubstitution}/TestColumnar.java | 10 +- .../polysubstitution}/TestHill.java | 8 +- .../polysubstitution}/TestMorse.java | 2 +- .../polysubstitution}/TestPlayfair.java | 8 +- .../polysubstitution}/TestPolybiusSquare.java | 8 +- .../polysubstitution}/TestRailFence.java | 8 +- .../polysubstitution}/TestTrifid.java | 12 +- 47 files changed, 289 insertions(+), 311 deletions(-) rename src/main/java/com/mattrixwv/{CipherStreamJava => cipherstream}/combination/ADFGVX.java (92%) rename src/main/java/com/mattrixwv/{CipherStreamJava => cipherstream}/combination/ADFGX.java (90%) rename src/main/java/com/mattrixwv/{CipherStreamJava/Exceptions => cipherstream/exceptions}/InvalidBaseException.java (80%) rename src/main/java/com/mattrixwv/{CipherStreamJava/Exceptions => cipherstream/exceptions}/InvalidCharacterException.java (80%) rename src/main/java/com/mattrixwv/{CipherStreamJava/Exceptions => cipherstream/exceptions}/InvalidInputException.java (80%) rename src/main/java/com/mattrixwv/{CipherStreamJava/Exceptions => cipherstream/exceptions}/InvalidKeywordException.java (80%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Affine.java (96%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Atbash.java (73%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Autokey.java (91%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Baconian.java (92%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/BaseX.java (94%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Beaufort.java (96%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Caesar.java (97%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/OneTimePad.java (85%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Porta.java (96%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Substitution.java (95%) rename src/main/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/Vigenere.java (93%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/Bifid.java (95%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/Columnar.java (92%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/Hill.java (95%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/Morse.java (98%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/Playfair.java (84%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/PolybiusSquare.java (97%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/RailFence.java (97%) rename src/main/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/Trifid.java (89%) rename src/test/java/com/mattrixwv/{CipherStreamJava => cipherstream}/combination/TestADFGVX.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava => cipherstream}/combination/TestADFGX.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestAffine.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestAtbash.java (99%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestAutokey.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestBaconian.java (95%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestBaseX.java (97%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestBeaufort.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestCaesar.java (99%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestOneTimePad.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestPorta.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestSubstitution.java (99%) rename src/test/java/com/mattrixwv/{CipherStreamJava/monoSubstitution => cipherstream/monosubstitution}/TestVigenere.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestBifid.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestColumnar.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestHill.java (99%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestMorse.java (96%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestPlayfair.java (99%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestPolybiusSquare.java (98%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestRailFence.java (99%) rename src/test/java/com/mattrixwv/{CipherStreamJava/polySubstitution => cipherstream/polysubstitution}/TestTrifid.java (98%) diff --git a/pom.xml b/pom.xml index 3149ba5..32c2d11 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 mattrixwv - CipherStreamJava + cipher-stream-java 1.0-SNAPSHOT CipherStreamJava @@ -13,8 +13,9 @@ UTF-8 - 11 - 11 + 18 + 18 + 18 @@ -27,7 +28,7 @@ com.mattrixwv matrix - 1.0-SNAPSHOT + 1.0 diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGVX.java b/src/main/java/com/mattrixwv/cipherstream/combination/ADFGVX.java similarity index 92% rename from src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGVX.java rename to src/main/java/com/mattrixwv/cipherstream/combination/ADFGVX.java index cd47ad8..bd8e20e 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGVX.java +++ b/src/main/java/com/mattrixwv/cipherstream/combination/ADFGVX.java @@ -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; diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGX.java b/src/main/java/com/mattrixwv/cipherstream/combination/ADFGX.java similarity index 90% rename from src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGX.java rename to src/main/java/com/mattrixwv/cipherstream/combination/ADFGX.java index 9a93b74..758ef09 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGX.java +++ b/src/main/java/com/mattrixwv/cipherstream/combination/ADFGX.java @@ -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(); diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidBaseException.java b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidBaseException.java similarity index 80% rename from src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidBaseException.java rename to src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidBaseException.java index 530cdad..f4911be 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidBaseException.java +++ b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidBaseException.java @@ -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(); } diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidCharacterException.java b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidCharacterException.java similarity index 80% rename from src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidCharacterException.java rename to src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidCharacterException.java index 717f050..c461908 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidCharacterException.java +++ b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidCharacterException.java @@ -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(); } diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidInputException.java b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidInputException.java similarity index 80% rename from src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidInputException.java rename to src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidInputException.java index e4fbf10..5da1dd0 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidInputException.java +++ b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidInputException.java @@ -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(); } diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidKeywordException.java b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidKeywordException.java similarity index 80% rename from src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidKeywordException.java rename to src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidKeywordException.java index 51f41cb..4b2360c 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/Exceptions/InvalidKeywordException.java +++ b/src/main/java/com/mattrixwv/cipherstream/exceptions/InvalidKeywordException.java @@ -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(); } diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Affine.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Affine.java similarity index 96% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Affine.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Affine.java index d2137d7..66e560e 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Affine.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Affine.java @@ -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; diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Atbash.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Atbash.java similarity index 73% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Atbash.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Atbash.java index 676efa8..778ddde 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Atbash.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Atbash.java @@ -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 = ""; diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Autokey.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Autokey.java similarity index 91% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Autokey.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Autokey.java index d169a21..39f552a 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Autokey.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Autokey.java @@ -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); diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Baconian.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Baconian.java similarity index 92% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Baconian.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Baconian.java index 97c7889..b6d4cea 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Baconian.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Baconian.java @@ -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 code = new ArrayList(Arrays.asList( + private static final ArrayList 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'); } diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/BaseX.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/BaseX.java similarity index 94% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/BaseX.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/BaseX.java index 1215b54..e213f96 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/BaseX.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/BaseX.java @@ -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{ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Beaufort.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Beaufort.java similarity index 96% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Beaufort.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Beaufort.java index bd4c61a..d3559ab 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Beaufort.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Beaufort.java @@ -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{ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Caesar.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Caesar.java similarity index 97% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Caesar.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Caesar.java index 860cc87..7c93779 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Caesar.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Caesar.java @@ -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{ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/OneTimePad.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/OneTimePad.java similarity index 85% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/OneTimePad.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/OneTimePad.java index 6a4fc3c..d191d1e 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/OneTimePad.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/OneTimePad.java @@ -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{ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Porta.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Porta.java similarity index 96% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Porta.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Porta.java index 958ce0c..af5b36a 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Porta.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Porta.java @@ -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': diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Substitution.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Substitution.java similarity index 95% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Substitution.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Substitution.java index d9c57a0..a7425c2 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Substitution.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Substitution.java @@ -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{ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Vigenere.java b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Vigenere.java similarity index 93% rename from src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Vigenere.java rename to src/main/java/com/mattrixwv/cipherstream/monosubstitution/Vigenere.java index 99a8417..b62598d 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Vigenere.java +++ b/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Vigenere.java @@ -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(); + offset = new ArrayList<>(); reset(); preserveCapitals = false; preserveWhitespace = false; preserveSymbols = false; } public Vigenere(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols){ - offset = new ArrayList(); + 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 getOffsets(){ + public List getOffsets(){ return offset; } //Encodes input using key and returns the result diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Bifid.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Bifid.java similarity index 95% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Bifid.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/Bifid.java index 2c05db8..8297962 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Bifid.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Bifid.java @@ -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 diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Columnar.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Columnar.java similarity index 92% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Columnar.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/Columnar.java index 8dcc798..6595d96 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Columnar.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Columnar.java @@ -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>(); - grid.add(new ArrayList(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(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>(); + grid = new ArrayList<>(); StringBuilder orderedKeyword = new StringBuilder(); for(int cnt : getKeywordAlphaLocations()){ orderedKeyword.append(keyword.charAt(cnt)); } - grid.add(new ArrayList(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()); + 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 originalLocations = getKeywordOriginalLocations(); - ArrayList longColumns = new ArrayList(); + ArrayList 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 colsAddedTo = new ArrayList(); + ArrayList colsAddedTo = new ArrayList<>(); if(removePadding){ ArrayList cols = getKeywordOriginalLocations(); Collections.reverse(cols); @@ -251,7 +251,7 @@ public class Columnar{ charsAdded = 0; } - ArrayList colsAddedTo = new ArrayList(); + ArrayList colsAddedTo = new ArrayList<>(); if(removePadding){ ArrayList 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 getKeywordAlphaLocations(){ - ArrayList orderedLocations = new ArrayList(); + ArrayList 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 orderedLocations = getKeywordAlphaLocations(); //Figure out what order the columns need rearanged to - ArrayList originalOrder = new ArrayList(); + ArrayList 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 listOrder){ //Create a new grid and make sure it is the same size as the original grid int numCol = grid.get(0).size(); - ArrayList> newGrid = new ArrayList>(grid.size()); + ArrayList> newGrid = new ArrayList<>(grid.size()); for(int cnt = 0;cnt < grid.size();++cnt){ - newGrid.add(new ArrayList(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>(); + grid = new ArrayList<>(); charsAdded = 0; } //Gets diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Hill.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Hill.java similarity index 95% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Hill.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/Hill.java index 2f80e7f..638210e 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Hill.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Hill.java @@ -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 vectors = new ArrayList(); + ArrayList 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 inputVectors = getInputVectors(); //Multiply the key by each vector and add the result to a new vector - ArrayList outputVectors = new ArrayList(); + ArrayList 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 outputVectors = new ArrayList(); + ArrayList outputVectors = new ArrayList<>(); for(ModMatrix inputVector : inputVectors){ ModMatrix outputVector = inverseKey.multiply(inputVector); outputVectors.add(outputVector); diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Morse.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Morse.java similarity index 98% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Morse.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/Morse.java index 4681ffc..0ca9e5a 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Morse.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Morse.java @@ -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{ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Playfair.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Playfair.java similarity index 84% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Playfair.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/Playfair.java index a1585d1..af142da 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Playfair.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Playfair.java @@ -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(); diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/PolybiusSquare.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/PolybiusSquare.java similarity index 97% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/PolybiusSquare.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/PolybiusSquare.java index 1a3a8c8..29ea26b 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/PolybiusSquare.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/PolybiusSquare.java @@ -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){ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/RailFence.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/RailFence.java similarity index 97% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/RailFence.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/RailFence.java index b760c27..7ec9d17 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/RailFence.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/RailFence.java @@ -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{ diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Trifid.java b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Trifid.java similarity index 89% rename from src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Trifid.java rename to src/main/java/com/mattrixwv/cipherstream/polysubstitution/Trifid.java index 49460dc..48b4a35 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Trifid.java +++ b/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Trifid.java @@ -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 locations = new ArrayList(); + ArrayList 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> groups = new ArrayList>(numGroups); + ArrayList> groups = new ArrayList<>(numGroups); for(int cnt = 0;cnt < numGroups;++cnt){ - groups.add(new ArrayList()); + 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 coordinates = new ArrayList(locations.size() * 3); + ArrayList coordinates = new ArrayList<>(locations.size() * 3); for(ArrayList group : groups){ //Split the coordinates up into 3 rows - ArrayList layers = new ArrayList(group.size()); - ArrayList rows = new ArrayList(group.size()); - ArrayList cols = new ArrayList(group.size()); + ArrayList layers = new ArrayList<>(group.size()); + ArrayList rows = new ArrayList<>(group.size()); + ArrayList 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 newLocations = new ArrayList(locations.size()); + ArrayList 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 locations = new ArrayList(); + ArrayList 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> groups = new ArrayList>(numGroups); + ArrayList> groups = new ArrayList<>(numGroups); for(int cnt = 0;cnt < numGroups;++cnt){ - groups.add(new ArrayList()); + 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 originalLocations = new ArrayList(locations.size()); + ArrayList originalLocations = new ArrayList<>(locations.size()); for(ArrayList group : groups){ //Read all of the coordinates from the group out into a row - ArrayList coordinates = new ArrayList(group.size() * 3); + ArrayList 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 originalGroup = new ArrayList(group.size()); + ArrayList 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{ diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/combination/TestADFGVX.java b/src/test/java/com/mattrixwv/cipherstream/combination/TestADFGVX.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/combination/TestADFGVX.java rename to src/test/java/com/mattrixwv/cipherstream/combination/TestADFGVX.java index f2166f2..e8a451e 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/combination/TestADFGVX.java +++ b/src/test/java/com/mattrixwv/cipherstream/combination/TestADFGVX.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/combination/TestADFGX.java b/src/test/java/com/mattrixwv/cipherstream/combination/TestADFGX.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/combination/TestADFGX.java rename to src/test/java/com/mattrixwv/cipherstream/combination/TestADFGX.java index 3bff42a..9258735 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/combination/TestADFGX.java +++ b/src/test/java/com/mattrixwv/cipherstream/combination/TestADFGX.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAffine.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAffine.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAffine.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAffine.java index 4d02f81..52bf5ee 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAffine.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAffine.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAtbash.java similarity index 99% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAtbash.java index 0c2f81f..21a2b70 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAtbash.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAutokey.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAutokey.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAutokey.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAutokey.java index c780fc3..fcfb559 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAutokey.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestAutokey.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaconian.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBaconian.java similarity index 95% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaconian.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBaconian.java index 1d11408..bc13af9 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaconian.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBaconian.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaseX.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBaseX.java similarity index 97% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaseX.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBaseX.java index 1482be5..2ea2c9f 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaseX.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBaseX.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBeaufort.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBeaufort.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBeaufort.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBeaufort.java index 59de9c0..0f99eae 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBeaufort.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestBeaufort.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestCaesar.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestCaesar.java similarity index 99% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestCaesar.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestCaesar.java index b9fd797..9587cdb 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestCaesar.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestCaesar.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestOneTimePad.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestOneTimePad.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestOneTimePad.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestOneTimePad.java index 1f07f03..6c20d9f 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestOneTimePad.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestOneTimePad.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestPorta.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestPorta.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestPorta.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestPorta.java index 97754d5..05e4108 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestPorta.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestPorta.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestSubstitution.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestSubstitution.java similarity index 99% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestSubstitution.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestSubstitution.java index 04000de..a8dbea3 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestSubstitution.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestSubstitution.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestVigenere.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java rename to src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestVigenere.java index 55297f0..cb85b8b 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java +++ b/src/test/java/com/mattrixwv/cipherstream/monosubstitution/TestVigenere.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestBifid.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestBifid.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestBifid.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestBifid.java index fa13fed..e7fcbe2 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestBifid.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestBifid.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestColumnar.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestColumnar.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestColumnar.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestColumnar.java index 648e41f..832e730 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestColumnar.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestColumnar.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestHill.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestHill.java similarity index 99% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestHill.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestHill.java index b82ac2e..573fa79 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestHill.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestHill.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestMorse.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestMorse.java similarity index 96% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestMorse.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestMorse.java index 9e1563b..6bf3b42 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestMorse.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestMorse.java @@ -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; diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestPlayfair.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestPlayfair.java similarity index 99% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestPlayfair.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestPlayfair.java index fe6ce2b..6c05113 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestPlayfair.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestPlayfair.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestPolybiusSquare.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestPolybiusSquare.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestPolybiusSquare.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestPolybiusSquare.java index 1113ad6..dd87338 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestPolybiusSquare.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestPolybiusSquare.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestRailFence.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestRailFence.java similarity index 99% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestRailFence.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestRailFence.java index b86fd4e..0eb87a1 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestRailFence.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestRailFence.java @@ -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 diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java similarity index 98% rename from src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java rename to src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java index 651a560..c416f45 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java @@ -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