Skip to content

Commit 966fedd

Browse files
Update playfair_cipher.cpp
1 parent e82c87b commit 966fedd

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

ciphers/playfair_cipher.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,17 @@ namespace ciphers {
217217
} // namespace ciphers
218218

219219
void test() {
220-
// Test 1
221-
std::string text1 = "HEYO";
222-
std::string encrypted1 = ciphers::playfair::encrypt(text1, "OLDTAVERN");
223-
std::string decrypted1 = ciphers::playfair::decrypt(encrypted1, "OLDTAVERN");
224-
std::cout << "Original text: " << text1;
225-
std::cout << " , Encrypted text (key = OLDTAVERN): " << encrypted1;
226-
std::cout << " , Decrypted text: " << decrypted1 << std::endl;
220+
// Test 1
221+
std::string text1 = "heyo";
222+
std::string encrypted1 = ciphers::playfair::encrypt(text1, "oldtavern");
223+
std::string decrypted1 = ciphers::playfair::decrypt(encrypted1, "oldtavern");
224+
assert(text1 == decrypted1);
227225

228226
// Test 2
229-
std::string text2 = "HELLO";
230-
std::string encrypted2 = ciphers::playfair::encrypt(text2, "OLDTAVERN");
231-
std::string decrypted2 = ciphers::playfair::decrypt(encrypted2, "OLDTAVERN");
232-
std::cout << "Original text: " << text2;
233-
std::cout << " , Encrypted text (key = OLDTAVERN): " << encrypted2;
234-
std::cout << " , Decrypted text: " << decrypted2 << std::endl;
227+
std::string text2 = "maid";
228+
std::string encrypted2 = ciphers::playfair::encrypt(text2, "oldtavern");
229+
std::string decrypted2 = ciphers::playfair::decrypt(encrypted2, "oldtavern");
230+
assert(text2 == decrypted2);
235231
}
236232

237233
/** Driver Code */

0 commit comments

Comments
 (0)