Skip to content

Commit

Permalink
ref(docs): make caesar cipher docs consistent (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptandcompile authored Jun 11, 2024
1 parent dbfef30 commit 1d0b131
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/ciphers/caesar.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
//! Caesar Cipher
//! Based on cipher_crypt::caesar
//!
//! # Algorithm
/// Encrypts a given [`&str`] using Caesar cipher.
/// Implements the Caesar Cipher based on cipher_crypt::caesar
///
/// Rotate each ascii character by shift.
/// Rotates each ascii character by shift.
/// The most basic example is ROT 13, which rotates 'a' to 'n'.
/// This implementation does not rotates unicode characters.
///
/// See [Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher) for more information.
///
/// # Arguments
///
/// `cipher` - String to transform.
///
/// `shift` - Amount to right-shift.
/// *`cipher` - A [`&str`] plain text to encrypt.
/// *`shift` - Amount to right-shift the text.
///
/// # Returns
///
/// An owned [`String`]
///
/// # Panic
///
/// This function won't panic
/// An owned [`String`] of the encrypted text.
///
/// # Examples
/// ```
///
/// ```rust
/// # use rust_algorithms::ciphers::caesar;
///
/// let encoded = caesar("one sheep two sheep", 3);
///
/// assert_eq!(encoded, "rqh vkhhs wzr vkhhs")
/// ```
pub fn caesar(cipher: &str, shift: u8) -> String {
Expand Down

0 comments on commit 1d0b131

Please sign in to comment.