Finished Trifid cipher
This commit is contained in:
@@ -33,7 +33,7 @@ public class TestTrifid{
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed uppercase encoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength
|
||||
//Test groupLength encoding
|
||||
inputString = "messagetoencode";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
@@ -70,21 +70,490 @@ public class TestTrifid{
|
||||
assertEquals("Trifid failed mixed case, whitespace, symbol, groupLength encoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCapitalEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
//TODO:
|
||||
Trifid cipher = new Trifid(false, true, true, '+');
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "GQDOKPDODLJVFLF";
|
||||
String output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no capital lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
keyword = "keyword";
|
||||
correctOutput = "GQDOKPDODLJVFLF";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no capital uppercase encoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength encoding
|
||||
inputString = "messagetoencode";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "GPJQDVDOFODLKLF";
|
||||
output = cipher.encode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no capital 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 no capital 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 no capital 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 no capital 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 no capital mixed case, whitespace, symbol, groupLength encoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
//TODO:
|
||||
Trifid cipher = new Trifid(true, false, true, '+');
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "gqdokpdodljvflf";
|
||||
String output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
keyword = "keyword";
|
||||
correctOutput = "GQDOKPDODLJVFLF";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace uppercase encoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength encoding
|
||||
inputString = "messagetoencode";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "gpjqdvdofodlklf";
|
||||
output = cipher.encode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no whitespace groupLength encoding.", correctOutput, output);
|
||||
|
||||
//Test whitespace encoding
|
||||
inputString = "message to encode";
|
||||
keyword = "keyword";
|
||||
correctOutput = "gqdokpdodljvflf";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace 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 no whitespace symbol encoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Gqdokpdod^ljvflf";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace mixed case, whitespace, symbol encoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Message to^encode";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "Gpjqdvdof^odlklf";
|
||||
output = cipher.encode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no whitespace mixed case, whitespace, symbol, groupLength encoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
//TODO:
|
||||
Trifid cipher = new Trifid(true, true, false, '+');
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "gqdokpdodljvflf";
|
||||
String output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
keyword = "keyword";
|
||||
correctOutput = "GQDOKPDODLJVFLF";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol uppercase encoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength encoding
|
||||
inputString = "messagetoencode";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "gpjqdvdofodlklf";
|
||||
output = cipher.encode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no symbol 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 no symbol whitespace encoding.", correctOutput, output);
|
||||
|
||||
//Test symbol encoding
|
||||
inputString = "message*to-encode";
|
||||
keyword = "keyword";
|
||||
correctOutput = "gqdokpdodljvflf";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol symbol encoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Gqdokpd odljvflf";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol mixed case, whitespace, symbol encoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Message to^encode";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "Gpjqdvd ofodlklf";
|
||||
output = cipher.encode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no symbol mixed case, whitespace, symbol, groupLength encoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
Trifid cipher = new Trifid(false, false, false, '+');
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "GQDOKPDODLJVFLF";
|
||||
String output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
keyword = "keyword";
|
||||
correctOutput = "GQDOKPDODLJVFLF";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure uppercase encoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength encoding
|
||||
inputString = "messagetoencode";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "GPJQDVDOFODLKLF";
|
||||
output = cipher.encode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed secure groupLength encoding.", correctOutput, output);
|
||||
|
||||
//Test whitespace encoding
|
||||
inputString = "message to encode";
|
||||
keyword = "keyword";
|
||||
correctOutput = "GQDOKPDODLJVFLF";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure whitespace encoding.", correctOutput, output);
|
||||
|
||||
//Test symbol encoding
|
||||
inputString = "message*to-encode";
|
||||
keyword = "keyword";
|
||||
correctOutput = "GQDOKPDODLJVFLF";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure symbol encoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
keyword = "keyword";
|
||||
correctOutput = "GQDOKPDODLJVFLF";
|
||||
output = cipher.encode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure mixed case, whitespace, symbol encoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Message to^encode";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "GPJQDVDOFODLKLF";
|
||||
output = cipher.encode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed secure mixed case, whitespace, symbol, groupLength encoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDecode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
//TODO:
|
||||
Trifid cipher = new Trifid(true, true, true, '+');
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "gqdokpdodljvflf";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "messagetoencode";
|
||||
String output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "GQDOKPDODLJVFLF";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed uppercase decoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength decoding
|
||||
inputString = "gpjqdvdofodlklf";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "messagetoencode";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed groupLength decoding.", correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "gqdokpd od ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message to encode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed whitespace decoding.", correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "gqdokpd*od-ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message*to-encode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed symbol decoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
inputString = "Gqdokpd od^ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Message to^encode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Gpjqdvd of^odlklf";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "Message to^encode";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed mixed case, whitespace, symbol, groupLength decoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCapitalDecode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
Trifid cipher = new Trifid(false, true, true, '+');
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "gqdokpdodljvflf";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "MESSAGETOENCODE";
|
||||
String output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no capital lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "GQDOKPDODLJVFLF";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no capital uppercase decoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength decoding
|
||||
inputString = "gpjqdvdofodlklf";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no capital groupLength decoding.", correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "gqdokpd od ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGE TO ENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no capital whitespace decoding.", correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "gqdokpd*od-ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGE*TO-ENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no capital symbol decoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
inputString = "Gqdokpd od^ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGE TO^ENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no capital mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Gpjqdvd of^odlklf";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "MESSAGE TO^ENCODE";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no capital mixed case, whitespace, symbol, groupLength decoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoWhitespaceDecode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
Trifid cipher = new Trifid(true, false, true, '+');
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "gqdokpdodljvflf";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "messagetoencode";
|
||||
String output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "GQDOKPDODLJVFLF";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace uppercase decoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength decoding
|
||||
inputString = "gpjqdvdofodlklf";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "messagetoencode";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no whitespace groupLength decoding.", correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "gqdokpd od ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "messagetoencode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace whitespace decoding.", correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "gqdokpd*od-ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message*to-encode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace symbol decoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
inputString = "Gqdokpd od^ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Messageto^encode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no whitespace mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Gpjqdvd of^odlklf";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "Messageto^encode";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no whitespace mixed case, whitespace, symbol, groupLength decoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoSymbolDeocde() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
Trifid cipher = new Trifid(true, true, false, '+');
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "gqdokpdodljvflf";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "messagetoencode";
|
||||
String output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "GQDOKPDODLJVFLF";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol uppercase decoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength decoding
|
||||
inputString = "gpjqdvdofodlklf";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "messagetoencode";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no symbol groupLength decoding.", correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "gqdokpd od ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message to encode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol whitespace decoding.", correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "gqdokpd*od-ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "messagetoencode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol symbol decoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
inputString = "Gqdokpd od^ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Message toencode";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed no symbol mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Gpjqdvd of^odlklf";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "Message toencode";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed no symbol mixed case, whitespace, symbol, groupLength decoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{
|
||||
Trifid cipher = new Trifid(false, false, false, '+');
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "gqdokpdodljvflf";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "MESSAGETOENCODE";
|
||||
String output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "GQDOKPDODLJVFLF";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure uppercase decoding.", correctOutput, output);
|
||||
|
||||
//Test groupLength decoding
|
||||
inputString = "gpjqdvdofodlklf";
|
||||
keyword = "keyword";
|
||||
int groupLength = 3;
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed secure groupLength decoding.", correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "gqdokpd od ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure whitespace decoding.", correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "gqdokpd*od-ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure symbol decoding.", correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
inputString = "Gqdokpd od^ljvflf";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, inputString);
|
||||
assertEquals("Trifid failed secure mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Throw in groupLength for good measure
|
||||
inputString = "Gpjqdvd of^odlklf";
|
||||
keyword = "keyword";
|
||||
groupLength = 3;
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(keyword, groupLength, inputString);
|
||||
assertEquals("Trifid failed secure mixed case, whitespace, symbol, groupLength decoding.", correctOutput, output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user