|
7 | 7 | * instead of individual letters. It uses a 5x5 grid filled with the letters of the alphabet (combining 'I' and 'J')
|
8 | 8 | * and a keyword to create the grid. Each pair of letters in the plaintext is encrypted by locating the letters in the grid.
|
9 | 9 | *
|
10 |
| - * ### Algorithm |
| 10 | + * @algorithm |
11 | 11 | * The encryption process works by first finding the letters of the digraph in the 5x5 grid:
|
12 | 12 | * - 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).
|
13 | 13 | * - 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).
|
14 | 14 | * - If the letters form a rectangle, each letter is replaced by the letter in its row at the other corner of the rectangle.
|
15 | 15 | *
|
16 | 16 | * Decryption reverses these steps using the same key.
|
17 | 17 | *
|
| 18 | + * @example |
18 | 19 | * For Example:
|
19 | 20 | * If the key is "PLAYFAIR", the 5x5 grid will be:
|
20 | 21 | * ```
|
|
33 | 34 | */
|
34 | 35 |
|
35 | 36 |
|
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 |
40 | 41 |
|
41 |
| -/** \namespace ciphers |
42 |
| - * \brief Algorithms for encryption and decryption |
| 42 | +/** @namespace ciphers |
| 43 | + * @brief Algorithms for encryption and decryption |
43 | 44 | */
|
44 | 45 | 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. |
47 | 48 | */
|
48 | 49 | namespace playfair {
|
49 | 50 |
|
@@ -215,9 +216,6 @@ namespace ciphers {
|
215 | 216 | } // namespace playfair
|
216 | 217 | } // namespace ciphers
|
217 | 218 |
|
218 |
| -/** |
219 |
| - * Function to test the Playfair cipher algorithm. |
220 |
| - */ |
221 | 219 | void test() {
|
222 | 220 | // Test 1
|
223 | 221 | std::string text1 = "HEYO";
|
|
0 commit comments