Struct cipher_crypt::affine::Affine

source ·
pub struct Affine { /* private fields */ }
Expand description

An Affine cipher.

This struct is created by the new() method. See its documentation for more.

Trait Implementations§

Initialise an Affine cipher given the key (a, b).

Panics
  • a or b are not in the inclusive range 1 - 26.
  • a has a factor in common with 26.

Encrypt a message using an Affine cipher.

Examples

Basic usage:

use cipher_crypt::{Cipher, Affine};

let a = Affine::new((3, 7));
assert_eq!("Hmmhnl hm qhvu!", a.encrypt("Attack at dawn!").unwrap());

Decrypt a message using an Affine cipher.

Examples

Basic usage:

use cipher_crypt::{Cipher, Affine};

let a = Affine::new((3, 7));
assert_eq!("Attack at dawn!", a.decrypt("Hmmhnl hm qhvu!").unwrap());

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.