[][src]Struct serde_encrypted_value::Key

pub struct Key<T> { /* fields omitted */ }

A key used to encrypt or decrypt values. It represents both an algorithm and a key.

Keys which have been deserialized from a string or file cannot encrypt new values; only freshly created keys have that ability. This is indicated by the type parameter T.

The canonical serialized representation of a Key is a string consisting of an algorithm identifier, followed by a :, followed by the base64 encoded bytes of the key. The Display and FromStr implementations serialize and deserialize in this format.

The only algorithm currently supported is AES 256 GCM, which uses the identifier AES.

Implementations

impl Key<ReadWrite>[src]

pub fn random_aes() -> Result<Key<ReadWrite>>[src]

Creates a random AES key.

pub fn encrypt(&mut self, value: &str) -> Result<String>[src]

Encrypts a string with this key.

impl Key<ReadOnly>[src]

pub fn from_file<P>(path: P) -> Result<Option<Key<ReadOnly>>> where
    P: AsRef<Path>, 
[src]

A convenience function which deserializes a Key from a file.

If the file does not exist, None is returned. Otherwise, the contents of the file are parsed via Key's FromStr implementation.

impl<T> Key<T>[src]

pub fn decrypt(&self, value: &str) -> Result<String>[src]

Decrypts a string with this key.

Trait Implementations

impl<T> Display for Key<T>[src]

impl FromStr for Key<ReadOnly>[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl<T> RefUnwindSafe for Key<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Key<T> where
    T: Send
[src]

impl<T> Sync for Key<T> where
    T: Sync
[src]

impl<T> Unpin for Key<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Key<T> where
    T: UnwindSafe
[src]

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> ToString for T where
    T: Display + ?Sized
[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.