Started Hill cipher

This commit is contained in:
2022-02-11 22:06:42 +00:00
parent 24ee26747c
commit aa45440dc4

View File

@@ -0,0 +1,115 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Hill.java
//Mattrixwv
// Created: 01-31-22
//Modified: 02-11-22
package com.mattrixwv.CipherStreamJava.polySubstitution;
import java.util.ArrayList;
import com.mattrixwv.matrix.ModMatrix;
public class Hill{
private boolean preserveCapitals;
private boolean preserveWhitespace;
private boolean preserveSymbols;
private boolean removePadding;
private String inputString;
private String outputString;
private char characterToAdd;
private int charsAdded;
private ModMatrix key;
private void setKey(ModMatrix key){
//TODO:
//Make sure the mod is correct
//Make sure the matrix is square
//Make sure the matrix is invertable
//Set the key
}
private void setInputString(String inputString){
//TODO:
//Remove anything that needs removed
//Make sure the input is correct length
//Make sure the input isn't blank
}
private void setCharacterToAdd(char characterToAdd){
//TODO:
//!Don't forget to account for capitals
//Make sure the character is a letter
//Save the characterToAdd
}
//TODO:
private ArrayList<ModMatrix> getInputVectors(){
//TODO: Return array of vectors
//Get the number of columns in the key
return null;
}
private String getOutputFromVectors(ArrayList<ModMatrix> outputVectors){
//TODO: Receive array of vectors
return null;
}
private String encode(){
//TODO:
return null;
}
private String decode(){
//TODO:
return null;
}
public Hill(){
preserveCapitals = false;
preserveWhitespace = false;
preserveSymbols = false;
setCharacterToAdd('x');
reset();
}
public Hill(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols, boolean removePadding){
this.preserveCapitals = preserveCapitals;
this.preserveWhitespace = preserveWhitespace;
this.preserveSymbols = preserveSymbols;
setCharacterToAdd('x');
reset();
}
public Hill(boolean preserveCapitals, boolean preserveWhitespace, boolean preserveSymbols, boolean removePadding, char characterToAdd){
this.preserveCapitals = preserveCapitals;
this.preserveWhitespace = preserveWhitespace;
this.preserveSymbols = preserveSymbols;
setCharacterToAdd(characterToAdd);
reset();
}
public String encode(int[][] key, String inputString){
return encode(new ModMatrix(key, 26), inputString);
}
public String encode(ModMatrix key, String inputString){
setKey(key);
setInputString(inputString);
return encode();
}
public String decode(int[][] key, String inputString){
return decode(new ModMatrix(key, 26), inputString);
}
public String decode(ModMatrix key, String inputString){
setKey(key);
setInputString(inputString);
return decode();
}
public void reset(){
inputString = "";
outputString = "";
key = new ModMatrix(26);
charsAdded = 0;
}
public String getInputString(){
return inputString;
}
public String getOutputString(){
return outputString;
}
public ModMatrix getKey(){
return key;
}
}