Trifid cipher started
This commit is contained in:
@@ -0,0 +1,90 @@
|
|||||||
|
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java
|
||||||
|
//Mattrixwv
|
||||||
|
// Created: 03-03-22
|
||||||
|
//Modified: 03-03-22
|
||||||
|
package com.mattrixwv.CipherStreamJava.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;
|
||||||
|
|
||||||
|
|
||||||
|
public class TestTrifid{
|
||||||
|
@Test
|
||||||
|
public void testEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||||
|
Trifid cipher = new Trifid(true, true, true, '+');
|
||||||
|
|
||||||
|
//Test lowercase encoding
|
||||||
|
String inputString = "messagetoencode";
|
||||||
|
String keyword = "keyword";
|
||||||
|
String correctOutput = "gqdokpdodljvflf";
|
||||||
|
String output = cipher.encode(keyword, inputString);
|
||||||
|
assertEquals("Trifid failed lowercase encoding.", correctOutput, output);
|
||||||
|
//Test uppercase encoding
|
||||||
|
inputString = "MESSAGETOENCODE";
|
||||||
|
keyword = "keyword";
|
||||||
|
correctOutput = "GQDOKPDODLJVFLF";
|
||||||
|
output = cipher.encode(keyword, inputString);
|
||||||
|
assertEquals("Trifid failed uppercase encoding.", correctOutput, output);
|
||||||
|
|
||||||
|
//Test groupLength
|
||||||
|
inputString = "messagetoencode";
|
||||||
|
keyword = "keyword";
|
||||||
|
int groupLength = 3;
|
||||||
|
correctOutput = "gpjqdvdofodlklf";
|
||||||
|
output = cipher.encode(keyword, groupLength, inputString);
|
||||||
|
assertEquals("Trifid failed groupLength encoding.", correctOutput, output);
|
||||||
|
|
||||||
|
//Test whitespace encoding
|
||||||
|
inputString = "message to encode";
|
||||||
|
keyword = "keyword";
|
||||||
|
correctOutput = "gqdokpd od ljvflf";
|
||||||
|
output = cipher.encode(keyword, inputString);
|
||||||
|
assertEquals("Trifid failed whitespace encoding.", correctOutput, output);
|
||||||
|
|
||||||
|
//Test symbol encoding
|
||||||
|
inputString = "message*to-encode";
|
||||||
|
keyword = "keyword";
|
||||||
|
correctOutput = "gqdokpd*od-ljvflf";
|
||||||
|
output = cipher.encode(keyword, inputString);
|
||||||
|
assertEquals("Trifid failed symbol encoding.", correctOutput, output);
|
||||||
|
|
||||||
|
//Test mixed case, whitespace, symbol encoding
|
||||||
|
inputString = "Message to^encode";
|
||||||
|
keyword = "keyword";
|
||||||
|
correctOutput = "Gqdokpd od^ljvflf";
|
||||||
|
output = cipher.encode(keyword, inputString);
|
||||||
|
assertEquals("Trifid failed mixed case, whitespace, symbol encoding.", correctOutput, output);
|
||||||
|
//Throw in groupLength for good measure
|
||||||
|
inputString = "Message to^encode";
|
||||||
|
keyword = "keyword";
|
||||||
|
groupLength = 3;
|
||||||
|
correctOutput = "Gpjqdvd of^odlklf";
|
||||||
|
output = cipher.encode(keyword, groupLength, inputString);
|
||||||
|
assertEquals("Trifid failed mixed case, whitespace, symbol, groupLength encoding.", correctOutput, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNoCapitalEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||||
|
//TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||||
|
//TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||||
|
//TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||||
|
//TODO:
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user