Skip to content

Commit

Permalink
feat(docs): document another_rot13 (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptandcompile authored Jun 9, 2024
1 parent 03c3b43 commit 3957787
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/ciphers/another_rot13.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/// Applies the ROT13 cipher to the given text.
///
/// ROT13 is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet.
/// The cipher wraps around, so 'Z' becomes 'M' and 'z' becomes 'm'.
/// Non-alphabetic characters are left unchanged.
///
/// # Arguments
///
/// * `text` - The text to be encrypted using ROT13 cipher.
///
/// # Returns
///
/// The encrypted text.
///
/// # Example
///
/// ```rust
/// use rust_algorithms::ciphers::another_rot13;
///
/// let text = "ABCzyx";
/// let encrypted = another_rot13(text);
///
/// assert_eq!(encrypted, "NOPmlk");
/// ```
///
pub fn another_rot13(text: &str) -> String {
let input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
let output = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";
Expand Down

0 comments on commit 3957787

Please sign in to comment.