[][src]Struct secretbox::SecretBox

pub struct SecretBox { /* fields omitted */ }

Methods

impl SecretBox[src]

pub fn new<R>(key: R, cipher: CipherType) -> Option<Self> where
    R: AsRef<[u8]>, 
[src]

Creates a new SecretBox instance

Returns None if the passed key is shorter than 32 bytes

pub fn from_random_key<R>(rng: &mut R, cipher: CipherType) -> (Self, [u8; 32]) where
    R: Rng + CryptoRng
[src]

Creates a new SecretBox instance with a generated key

pub fn seal(&self, message: &[u8], nonce: [u8; 24]) -> Vec<u8>[src]

This function returns an encrypted and authenticated copy of the message. The key and nonce pair must be unique for every message.

pub fn easy_seal(&self, message: &[u8]) -> Vec<u8>[src]

This function works like the above, except that it automatically generates a unique nonce.

pub fn easy_unseal(&self, data: &[u8]) -> Option<Vec<u8>>[src]

This function works like unseal, except that it finds the nonce automatically.

pub fn unseal(&self, data: &[u8], nonce: [u8; 24]) -> Option<Vec<u8>>[src]

This function tries to authenticate and decrypt a box

Trait Implementations

impl Eq for SecretBox[src]

impl Clone for SecretBox[src]

impl PartialEq<SecretBox> for SecretBox[src]

impl Copy for SecretBox[src]

impl Debug for SecretBox[src]

Auto Trait Implementations

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

impl<T> From<T> for 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.

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

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

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,