mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-06 18:33:58 -05:00
Added new tests for Playfair
This commit is contained in:
23
testMain.hpp
23
testMain.hpp
@@ -340,6 +340,29 @@ bool playfairTest(std::string& errorString){
|
||||
passed = false;
|
||||
}
|
||||
|
||||
//Test from wikipedia
|
||||
keyword = "Playfair Example";
|
||||
inputString = "Hide the gold in the tree stum";
|
||||
outputString = "BMODZBXDNABEKUDMUIXMMOUVIM";
|
||||
//Setup the cipher
|
||||
cipherString = cipher.encode(keyword, inputString);
|
||||
//If the cipher didn't spit out the correct string throw an error
|
||||
if(cipherString != outputString){
|
||||
errorString += testingError(ENCODE, inputString, outputString, cipherString);
|
||||
passed = false;
|
||||
}
|
||||
//This removes the spaces and turns everything capital so the reverse will work correctly
|
||||
inputString = cipher.getInputString();
|
||||
|
||||
//Do the same thing in reverse
|
||||
cipher.reset();
|
||||
cipherString = cipher.decode(keyword, outputString);
|
||||
//If the cipher didn't spit out the correct string throw an error
|
||||
if(cipherString != inputString){
|
||||
errorString += testingError(DECODE, outputString, inputString, cipherString);
|
||||
passed = false;
|
||||
}
|
||||
|
||||
//Return if the cipher passed the tests
|
||||
return passed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user