Trait Encryptable
Source pub trait Encryptable<const KEY_SIZE: usize> {
// Required methods
fn encrypt(
&self,
password: String,
strategy: KeyDerivationStrategy,
) -> Vec<u8> ⓘ;
fn encrypt_with_key(&self, key: &Key<KEY_SIZE, 16>) -> Vec<u8> ⓘ;
fn encrypt_with_raw_key(&self, key: [u8; KEY_SIZE]) -> Vec<u8> ⓘ;
fn encrypt_with_metadata<T>(
&self,
key: [u8; KEY_SIZE],
metadata: T,
) -> Vec<u8> ⓘ
where T: From<Vec<u8>> + Into<Vec<u8>> + Clone;
}
Expand description
The Encryptable trait provides a common interface for encryption operations.
It is implemented by types that can be encrypted.
§Type Parameters
KEY_SIZE - The size of the key to be used for encryption.
§Methods
encrypt - Encrypts the type using a specified password and key derivation strategy.
encrypt_with_key - Encrypts the type using a specified key.
encrypt_with_metadata - Encrypts the type using a specified key and metadata.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Encrypts a &str using a provided password.
§Arguments
password: The password to use for key derivation.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a string using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a string using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts an &str using a provided key and metadata.
§Arguments
key: The 32-byte cipher key used for encryption.
metadata: The metadata to be associated with the encrypted data.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a slice of bytes using a provided password.
§Arguments
password: The password to use for key derivation.
strategy: The key derivation strategy to use.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a slice of bytes using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a slice of bytes using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a slice of bytes using a provided key and metadata.
§Arguments
key: The 32-byte cipher key used for encryption.
metadata: The metadata to be associated with the encrypted data.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a string using a provided password.
§Arguments
key: The 32-byte cipher key used for encryption.
strategy: The key derivation strategy to use.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a String using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a String using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a String using a provided key and metadata.
§Arguments
key: The 32-byte cipher key used for encryption.
metadata: The metadata to be associated with the encrypted data.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a vector of bytes using a provided password.
§Arguments
password: The password to use for key derivation.
strategy: The key derivation strategy to use.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a vector of bytes using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a vector of bytes using a provided key.
§Arguments
key: The 32-byte cipher key used for encryption.
§Returns
A Vec<u8> containing the encrypted data.
Encrypts a vector of bytes using a provided key and metadata.
§Arguments
key: The 32-byte cipher key used for encryption.
metadata: The metadata to be associated with the encrypted data.
§Returns
A Vec<u8> containing the encrypted data.