From cb7bf1883693acdf888d6c5ba14b3eb13cb94f6f Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Tue, 4 Jan 2022 22:47:14 -0500 Subject: [PATCH] Fixed typos --- .../java/mattrixwv/CipherStreamJava/Playfair.java | 13 ++++++++----- .../mattrixwv/CipherStreamJava/TestPlayfair.java | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/mattrixwv/CipherStreamJava/Playfair.java b/src/main/java/mattrixwv/CipherStreamJava/Playfair.java index 9ec148a..f883403 100644 --- a/src/main/java/mattrixwv/CipherStreamJava/Playfair.java +++ b/src/main/java/mattrixwv/CipherStreamJava/Playfair.java @@ -45,7 +45,7 @@ public class Playfair{ private String inputString; //The message that needs to be encoded/decoded private String outputString; //The encoded/decoded message private String keyword; //The keyword used to create the grid - private char[][] grid; //The grid used to encoded/decode the message + private char[][] grid; //The grid used to encode/decode the message //Create the grid from the keyword private void createGrid(){ for(int row = 0;row < 5;++row){ @@ -156,13 +156,13 @@ public class Playfair{ this.inputString = inputString; } } - //Returns the inputs string ready for encoding + //Returns the input string ready for encoding private String getPreparedInputString(){ String cleanString = inputString.toUpperCase(); cleanString = cleanString.replaceAll("[^A-Z]", ""); return cleanString; } - //Strips invalid character from the keyword and creates the grid + //Strips invalid characters from the keyword and creates the grid private void setKeyword(String key){ //Change everything to uppercase key = key.toUpperCase(); @@ -223,7 +223,7 @@ public class Playfair{ } outputString = fullOutput.toString(); } - //Encoded inputString using the Playfair cipher and stores the result in outputString + //Encodes inputString using the Playfair cipher and stores the result in outputString private String encode() throws Exception{ StringBuilder output = new StringBuilder(); int inputCnt = 0; @@ -347,6 +347,9 @@ public class Playfair{ //Makes sure all variables are empty public void reset(){ grid = new char[5][5]; + inputString = ""; + outputString = ""; + keyword = ""; } //Gets public char getReplaced(){ @@ -354,7 +357,7 @@ public class Playfair{ } public void setReplaced(char replaced) throws InvalidCharacterException{ if(!Character.isAlphabetic(replaced)){ - throw new InvalidCharacterException("The replaced characgter must be a letter"); + throw new InvalidCharacterException("The replaced character must be a letter"); } if(replaced == replacer){ diff --git a/src/test/java/mattrixwv/CipherStreamJava/TestPlayfair.java b/src/test/java/mattrixwv/CipherStreamJava/TestPlayfair.java index 187d0de..5661bee 100644 --- a/src/test/java/mattrixwv/CipherStreamJava/TestPlayfair.java +++ b/src/test/java/mattrixwv/CipherStreamJava/TestPlayfair.java @@ -51,7 +51,7 @@ public class TestPlayfair{ output = cipher.decode(keyword, inputString); assertEquals("Playfair failed symbol decoding.", correctOutput, output); - //Test mixed case, whtiespace, symbol decoding + //Test mixed case, whitespace, symbol decoding inputString = "Bmod zbx dnab ek - udm@uixmm+ouvif"; keyword = "Playfair Example"; correctOutput = "Hide the gold in - the@trexe+stump";