Skip to content

Commit 9221252

Browse files
Update playfair_cipher.cpp
1 parent 7333371 commit 9221252

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

ciphers/playfair_cipher.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
* instead of individual letters. It uses a 5x5 grid filled with the letters of the alphabet (combining 'I' and 'J')
88
* and a keyword to create the grid. Each pair of letters in the plaintext is encrypted by locating the letters in the grid.
99
*
10-
* ### Algorithm
10+
* @algorithm
1111
* The encryption process works by first finding the letters of the digraph in the 5x5 grid:
1212
* - If the two letters are in the same row, each letter is replaced by the letter to its immediate right (wrapping to the leftmost letter if needed).
1313
* - If the two letters are in the same column, each letter is replaced by the letter immediately below it (wrapping to the topmost letter if needed).
1414
* - If the letters form a rectangle, each letter is replaced by the letter in its row at the other corner of the rectangle.
1515
*
1616
* Decryption reverses these steps using the same key.
1717
*
18+
* @example
1819
* For Example:
1920
* If the key is "PLAYFAIR", the 5x5 grid will be:
2021
* ```
@@ -33,17 +34,17 @@
3334
*/
3435

3536

36-
#include <iostream>
37-
#include <vector>
38-
#include <string>
39-
#include <cassert>
37+
#include <iostream> // For input/output stream operations
38+
#include <vector> // For using vectors to create the 5x5 grid
39+
#include <string> // For handling strings
40+
#include <cassert> // For assertions in case of unexpected input
4041

41-
/** \namespace ciphers
42-
* \brief Algorithms for encryption and decryption
42+
/** @namespace ciphers
43+
* @brief Algorithms for encryption and decryption
4344
*/
4445
namespace ciphers {
45-
/** \namespace playfair
46-
* \brief Functions for [Playfair cipher](https://en.wikipedia.org/wiki/Playfair_cipher) algorithm.
46+
/** @namespace playfair
47+
* @brief Functions for [Playfair cipher](https://en.wikipedia.org/wiki/Playfair_cipher) algorithm.
4748
*/
4849
namespace playfair {
4950

@@ -215,9 +216,6 @@ namespace ciphers {
215216
} // namespace playfair
216217
} // namespace ciphers
217218

218-
/**
219-
* Function to test the Playfair cipher algorithm.
220-
*/
221219
void test() {
222220
// Test 1
223221
std::string text1 = "HEYO";

0 commit comments

Comments
 (0)