Skip to content

Commit 3957787

Browse files
feat(docs): document another_rot13 (#75)
1 parent 03c3b43 commit 3957787

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/ciphers/another_rot13.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
/// Applies the ROT13 cipher to the given text.
2+
///
3+
/// ROT13 is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet.
4+
/// The cipher wraps around, so 'Z' becomes 'M' and 'z' becomes 'm'.
5+
/// Non-alphabetic characters are left unchanged.
6+
///
7+
/// # Arguments
8+
///
9+
/// * `text` - The text to be encrypted using ROT13 cipher.
10+
///
11+
/// # Returns
12+
///
13+
/// The encrypted text.
14+
///
15+
/// # Example
16+
///
17+
/// ```rust
18+
/// use rust_algorithms::ciphers::another_rot13;
19+
///
20+
/// let text = "ABCzyx";
21+
/// let encrypted = another_rot13(text);
22+
///
23+
/// assert_eq!(encrypted, "NOPmlk");
24+
/// ```
25+
///
126
pub fn another_rot13(text: &str) -> String {
227
let input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
328
let output = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";

0 commit comments

Comments
 (0)