Struct common_crypto::cryptor::Cryptor[][src]

pub struct Cryptor { /* fields omitted */ }

A cryptor supporting all of the block and stream ciphers provided by the common crypto library.

let config = Config::RC4 { key: b"Key" };
assert_eq!(
    Cryptor::encrypt(&config, b"Plaintext").unwrap(),
    &[0xbb, 0xf3, 0x16, 0xe8, 0xd9, 0x40, 0xaf, 0x0a, 0xd3]
);

Implementations

impl Cryptor[src]

pub fn new_encryptor<'a>(config: &Config<'a>) -> Result<Self, CryptorError>[src]

pub fn new_decryptor<'a>(config: &Config<'a>) -> Result<Self, CryptorError>[src]

pub fn update(
    &self,
    input: impl AsRef<[u8]>,
    output: &mut Vec<u8>
) -> Result<(), CryptorError>
[src]

Encrypts the data and writes to the provided buffer. The buffer will be resized as required, and will be cleared on error.

pub fn finish(self, output: &mut Vec<u8>) -> Result<(), CryptorError>[src]

Finalises the encryption, returning any remaining data where appropriate. The cryptor cannot be used again.

impl Cryptor[src]

pub fn encrypt<'a>(
    config: &Config<'a>,
    input: impl AsRef<[u8]>
) -> Result<Vec<u8>, CryptorError>
[src]

pub fn decrypt<'a>(
    config: &Config<'a>,
    input: impl AsRef<[u8]>
) -> Result<Vec<u8>, CryptorError>
[src]

Trait Implementations

impl Debug for Cryptor[src]

impl<'a> Drop for Cryptor[src]

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.