[−][src]Struct serde_encrypted_value::Key
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]
P: AsRef<Path>,
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]
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Key<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for Key<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Key<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Key<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Key<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,