Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned up the docs in caesar.rs to match the same formatting and sty… #77

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading