Struct cienli::ciphers::caesar::Caesar[][src]

pub struct Caesar { /* fields omitted */ }

Caesar Cipher

The struct is generated through the new() function.

Implementations

impl Caesar[src]

pub fn new(rotation: u8) -> Result<Caesar, &'static str>[src]

Initialize a caesar cipher with a rotation.

Examples:

use cienli::ciphers::caesar::Caesar;
let caesar = Caesar::new(5).unwrap();

Errors:

The rotation must be in range 1 and 26.

pub fn encipher(&self, message: &str) -> String[src]

Enciphers a message with the caesar cipher.

Examples:

  • Encipher with five times rotation:
use cienli::ciphers::caesar::Caesar;
let caesar = Caesar::new(5).unwrap();

assert_eq!("Mjqqt, Ymnx Nx F Yjxy", caesar.encipher("Hello, This Is A Test"));

pub fn decipher(&self, message: &str) -> String[src]

Deciphers a cipher with the caesar cipher.

Examples:

  • Decipher with five times rotation:
use cienli::ciphers::caesar::Caesar;
let caesar = Caesar::new(5).unwrap();

assert_eq!("Hello, This Is A Test", caesar.decipher("Mjqqt, Ymnx Nx F Yjxy"));

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.