[][src]Struct camellia_rs::CamelliaCipher

pub struct CamelliaCipher { /* fields omitted */ }

A structure representing cipher.

Methods

impl CamelliaCipher[src]

pub fn new(key: &[u8]) -> Result<Self, InvalidKeyLength>[src]

Creates new CamelliaCipher instance from variable length key.

Errors

If key.len() is other than 16, 24 and 32, an error will be returned.

Examples

let key = [0u8; 16];
assert!(CamelliaCipher::new(&key).is_ok());

let key = [0u8; 17];
assert!(CamelliaCipher::new(&key).is_err());

pub fn encrypt(&self, block: &mut Block)[src]

Encrypts given block in-place.

Examples

let key = [0u8; 16];
let data = [0u8; 16];

let cipher = CamelliaCipher::new(&key).unwrap();
let mut block = Block::from(data);

cipher.encrypt(&mut block);
let encrypted: [u8; 16] = block.into();

pub fn decrypt(&self, block: &mut Block)[src]

Decrypts given block in-place.

Examples

let key = [0u8; 16];
let data = [0u8; 16];

let cipher = CamelliaCipher::new(&key).unwrap();
let mut block = Block::from(data);

cipher.decrypt(&mut block);
let decrypted: [u8; 16] = block.into();

Trait Implementations

impl Clone for CamelliaCipher[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for CamelliaCipher[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.