Struct serde_encrypted_value::Key
[−]
[src]
pub struct Key(_);
A key used to encrypt or decrypt values. It represents both an algorithm and a key.
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
.
Methods
impl Key
[src]
fn random_aes() -> Result<Key>
Creates a random AES key.
fn from_file<P>(path: P) -> Result<Option<Key>> where
P: AsRef<Path>,
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.
fn encrypt(&self, value: &str) -> Result<String>
Encrypts a string with this key.
fn decrypt(&self, value: &str) -> Result<String>
Decrypts a string with this key.