Struct Baconian

Source
pub struct Baconian { /* private fields */ }
Expand description

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

Trait Implementations§

Source§

impl Cipher for Baconian

Source§

fn new(key: (bool, Option<String>)) -> Baconian

Initialise a Baconian cipher

The key tuple maps to the following: (bool, Option<str>) = (use_distinct_alphabet, decoy_text). Where …

  • The encoding will be use_distinct_alphabet for all alphabetical characters, or classical where I, J, U and V are mapped to the same value pairs
  • An optional decoy message that will will be used to hide the message - default is boilerplate “Lorem ipsum” text.
Source§

fn encrypt(&self, message: &str) -> Result<String, &'static str>

Encrypt a message using the Baconian cipher

  • The message to be encrypted can only be ~18% of the decoy_text as each character of message is encoded by 5 encoding characters AAAAA, AAAAB, etc.
  • The italicised ciphertext is then hidden in a decoy text, where, for each ‘B’ in the ciphertext, the character is italicised in the decoy_text.
§Examples

Basic usage:

use cipher_crypt::{Cipher, Baconian};

let b = Baconian::new((false, None));;
let message = "Hello";
let cipher_text = "Lo𝘳𝘦𝘮 ip𝘴um d𝘰l𝘰𝘳 s𝘪t 𝘢𝘮e𝘵, 𝘤𝘰n";

assert_eq!(cipher_text, b.encrypt(message).unwrap());
Source§

fn decrypt(&self, message: &str) -> Result<String, &'static str>

Decrypt a message that was encrypted with the Baconian cipher

§Examples

Basic usage:

use cipher_crypt::{Cipher, Baconian};

let b = Baconian::new((false, None));;
let cipher_text = "Lo𝘳𝘦𝘮 ip𝘴um d𝘰l𝘰𝘳 s𝘪t 𝘢𝘮e𝘵, 𝘯𝘦 t";

assert_eq!("HELLO", b.decrypt(cipher_text).unwrap());
Source§

type Key = (bool, Option<String>)

Source§

type Algorithm = Baconian

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.