Struct encryptfile::Config [] [src]

pub struct Config {
    // some fields omitted
}

The main Configuration type. This is a Builder object 1.

A config object can be reused; for instance, you can initially configure it for encryption using encrypt(), then switch it to decryption with decrypt().

Methods

impl Config

fn new() -> Self

Constructs a new Config with default settings. At a minimum, you must set input streams and a password method, and configure it for encryption or decryption.

fn decrypt(&mut self) -> &mut Self

Enable decryption mode.

fn encrypt(&mut self) -> &mut Self

Enable encryption mode.

fn input_stream(&mut self, is: InputStream) -> &mut Self

Set the input stream.

fn output_stream(&mut self, os: OutputStream) -> &mut Self

Set the output stream.

fn output_options(&mut self, opts: HashSet<OutputOption>) -> &mut Self

Set output options.

fn add_output_option(&mut self, opt: OutputOption) -> &mut Self

Add an output option.

fn remove_output_option(&mut self, opt: OutputOption) -> &mut Self

Remove an output option.

fn rng_mode(&mut self, rng_mode: RngMode) -> &mut Self

Set the random number mode. See the RngMode enum for information on how this is used.

fn initialization_vector(&mut self, initialization_vector: InitializationVector) -> &mut Self

Set the method of determining the initialization vector.

fn password(&mut self, password: PasswordType) -> &mut Self

Set the password method. Also clears the derived key.

fn salt(&mut self, salt: &str) -> &mut Self

Set the salt. Only used in password methods that require it; if not set, defaults to "DefaultSalt".

fn encryption_method(&mut self, encryption_method: EncryptionMethod) -> &mut Self

Set the encryption method.

fn buffer_size(&mut self, buffer_size: usize) -> &mut Self

Set the buffer size used for encryption and decryption. Default is 65536 bytes.

fn derive_key(&mut self) -> Result<PwKeyArray, EncryptError>

Derive the encryption key. The key is returned and is also cached on this object (accessible via get_derived_key()). See that function for details on how long this cached version persists.

It is not necessary to call this if you are just calling process() on a file. But it is useful if you want to use the key to decrypt many files, or if you want to use the key for other purposes (such as calculating HMACs).

fn validate(&self) -> Result<(), ValidateError>

Validate the encryption object; it is not necessary to call this manually since the configuration will be validated when it is used.

fn get_mode(&self) -> &Mode

fn get_input_stream(&self) -> &InputStream

fn get_output_stream(&self) -> &OutputStream

fn get_output_format(&self) -> &OutputFormat

fn get_output_options(&self) -> &HashSet<OutputOption>

fn get_rng_mode(&self) -> &RngMode

fn get_initialization_vector(&self) -> &InitializationVector

fn get_password(&self) -> &PasswordType

fn get_salt(&self) -> &str

fn get_encryption_method(&self) -> &EncryptionMethod

fn get_buffer_size(&self) -> usize

fn get_derived_key(&self) -> Option<PwKeyArray>

If derive_key() has been called, returns the derived encryption key. Otherwise returns None. Each time password() is called, the derived key will be reset to None.

Trait Implementations

Derived Implementations

impl Clone for Config

fn clone(&self) -> Config

fn clone_from(&mut self, source: &Self)