[][src]Trait bacon_cipher::BaconCodec

pub trait BaconCodec {
    type ABTYPE;
    type CONTENT;
    fn encode_elem(&self, elem: &Self::CONTENT) -> Vec<Self::ABTYPE>;
fn decode_elems(&self, elems: &[Self::ABTYPE]) -> Self::CONTENT;
fn a(&self) -> Self::ABTYPE;
fn b(&self) -> Self::ABTYPE;
fn encoded_group_size(&self) -> usize;
fn is_a(&self, elem: &Self::ABTYPE) -> bool;
fn is_b(&self, elem: &Self::ABTYPE) -> bool; fn encode(&self, input: &[Self::CONTENT]) -> Vec<Self::ABTYPE> { ... }
fn decode(&self, input: &[Self::ABTYPE]) -> Vec<Self::CONTENT> { ... } }

A codec that enables encoding and decoding based on the Bacon's cipher

Associated Types

type ABTYPE

The type of the substitution characters A and B that produce a cipher output like ABABBBABBABAAABAABAAAAABABAAAAAABAABAABAABABBAABAABAAABBAAABAAAAAAABBAAABAA

Can be char, bool or whatever

type CONTENT

The type of the content to be encoded to or decoded.

Loading content...

Required methods

fn encode_elem(&self, elem: &Self::CONTENT) -> Vec<Self::ABTYPE>

Encodes a single emenent of Self::CONTENT to a Vec of Self::ABTYPE.

fn decode_elems(&self, elems: &[Self::ABTYPE]) -> Self::CONTENT

Decode an array of elements to produce one element of Self::CΟΝΤΕΝΤ

fn a(&self) -> Self::ABTYPE

Returns the A substitution element.

fn b(&self) -> Self::ABTYPE

Returns the B substitution element.

fn encoded_group_size(&self) -> usize

Returns the the size of the group of elements that represent a content encoding.

E.g.: For the default Bacon's cipher, this is 5.

fn is_a(&self, elem: &Self::ABTYPE) -> bool

Tests whether an element equals with the A substitution element.

fn is_b(&self, elem: &Self::ABTYPE) -> bool

Tests whether an element equals with the B substitution element.

Loading content...

Provided methods

fn encode(&self, input: &[Self::CONTENT]) -> Vec<Self::ABTYPE>

Encode an array of some type Self::CONTENT

E.g. For CONTENT=char, ABTYPE=char, a='A' and b='B', the encoding of ['M','y',' ','s','e','c','r','e','t'] is ABABBBABBABAAABAABAAAAABABAAAAAABAABAABA

fn decode(&self, input: &[Self::ABTYPE]) -> Vec<Self::CONTENT>

Decode an array of some type Self::ABTYPE.

E.g. For CONTENT=char, ABTYPE=char, a='A' and b='B', the decoding of ABABBBABBABAAABAABAAAAABABAAAAAABAABAABA is ['M','Y','S','E','C','R','E','T']

Loading content...

Implementors

impl<T: PartialEq + Clone> BaconCodec for CharCodec<T>[src]

type ABTYPE = T

type CONTENT = char

impl<T: PartialEq + Clone> BaconCodec for CharCodecV2<T>[src]

type ABTYPE = T

type CONTENT = char

Loading content...