Updated Vigenere to work with Autokey
This commit is contained in:
@@ -9,13 +9,13 @@ import java.util.ArrayList;
|
||||
|
||||
public class Vigenere{
|
||||
public static final String version = "1.0"; //The current library's version number
|
||||
private String inputString; //This is the string that needs encoded/decoded
|
||||
private String outputString; //This is the string that is output after encoding/decoding
|
||||
private String keyword; //This is the keyword that is resposible for determining the offsets that you change each character by
|
||||
private ArrayList<Integer> offset; //Holds the offsets coputed from each character in the keyword
|
||||
protected String inputString; //This is the string that needs encoded/decoded
|
||||
protected String outputString; //This is the string that is output after encoding/decoding
|
||||
protected String keyword; //This is the keyword that is resposible for determining the offsets that you change each character by
|
||||
protected ArrayList<Integer> offset; //Holds the offsets coputed from each character in the keyword
|
||||
|
||||
//Uses keyword to calculate the offset for the Caesar cipher for each character
|
||||
private void setOffset(){
|
||||
protected void setOffset(){
|
||||
//Reserve the correct size to increase speed later
|
||||
offset.ensureCapacity(keyword.length());
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Vigenere{
|
||||
}
|
||||
}
|
||||
//Sets inputString
|
||||
private void setInputString(String input){
|
||||
protected void setInputString(String input){
|
||||
//Convert all letters to uppercase
|
||||
input = input.toUpperCase();
|
||||
//Remove all characters except capital letters
|
||||
@@ -35,7 +35,7 @@ public class Vigenere{
|
||||
inputString = input;
|
||||
}
|
||||
//Sets keyword
|
||||
private void setKeyword(String key) throws Exception{
|
||||
protected void setKeyword(String key) throws Exception{
|
||||
//Convert all letters to uppercase
|
||||
key = key.toUpperCase();
|
||||
//Remove all characters except capital letters
|
||||
@@ -52,7 +52,7 @@ public class Vigenere{
|
||||
}
|
||||
}
|
||||
//Encodes inputString and stores the result in outputString
|
||||
private String encode(){
|
||||
protected String encode(){
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
//Step through every character in the inputString and advance it the correct amount, according to offset
|
||||
@@ -72,7 +72,7 @@ public class Vigenere{
|
||||
return outputString;
|
||||
}
|
||||
//Decodes inputString and stores the result in outputString
|
||||
private String decode(){
|
||||
protected String decode(){
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
//Step through every character in the inputString and advance it the correct amount, according to offset
|
||||
|
||||
Reference in New Issue
Block a user