pub struct EncValue {
pub header: EncValueHeader,
pub payload: Bytes,
}Expand description
An encrypted value
Anc function from this which uses the static encryption keys for ease of use will
error if you do not call EncKeys::init() once during your application start up.
If you want to use dynamic keys, use the appropriate functions.
Fields§
§header: EncValueHeader§payload: BytesImplementations§
source§impl EncValue
impl EncValue
sourcepub fn encrypt(value: &[u8]) -> Result<Self, CryptrError>
pub fn encrypt(value: &[u8]) -> Result<Self, CryptrError>
Encrypt a value with the statically initialized encryption keys
Panics
If init() has not been called on valid EncKeys once before
sourcepub fn encrypt_with_password(
value: &[u8],
password: &str
) -> Result<Self, CryptrError>
pub fn encrypt_with_password( value: &[u8], password: &str ) -> Result<Self, CryptrError>
Encrypt a value with a given password
sourcepub async fn encrypt_to_file(
value: &[u8],
path: &str
) -> Result<(), CryptrError>
pub async fn encrypt_to_file( value: &[u8], path: &str ) -> Result<(), CryptrError>
Encrypt a value with the statically initialized encryption keys into a file
Panics
If init() has not been called on valid EncKeys once before
sourcepub async fn encrypt_to_file_with_password(
value: &[u8],
path: &str,
password: &str
) -> Result<(), CryptrError>
pub async fn encrypt_to_file_with_password( value: &[u8], path: &str, password: &str ) -> Result<(), CryptrError>
Encrypt a value with a given password into a file
sourcepub fn encrypt_with_keys(
value: &[u8],
enc_keys: &EncKeys
) -> Result<Self, CryptrError>
pub fn encrypt_with_keys( value: &[u8], enc_keys: &EncKeys ) -> Result<Self, CryptrError>
Encrypt a value with the given encryption keys.
It will by default always take the active keys.
sourcepub fn encrypt_with_key_id(
value: &[u8],
enc_key_id: String
) -> Result<Self, CryptrError>
pub fn encrypt_with_key_id( value: &[u8], enc_key_id: String ) -> Result<Self, CryptrError>
Encrypt a value with a specific Key ID from the statically initialized encryption keys
sourcepub fn decrypt(self) -> Result<Bytes, CryptrError>
pub fn decrypt(self) -> Result<Bytes, CryptrError>
Decrypt a value with the statically initialized encryption keys
sourcepub fn decrypt_bytes(bytes: &mut Bytes) -> Result<Bytes, CryptrError>
pub fn decrypt_bytes(bytes: &mut Bytes) -> Result<Bytes, CryptrError>
Decrypt a given Bytes directly
sourcepub fn decrypt_with_keys(self, enc_keys: &EncKeys) -> Result<Bytes, CryptrError>
pub fn decrypt_with_keys(self, enc_keys: &EncKeys) -> Result<Bytes, CryptrError>
Decrypt a value using the given encryption keys
sourcepub fn decrypt_bytes_with_keys(
bytes: &mut Bytes,
enc_keys: &EncKeys
) -> Result<Bytes, CryptrError>
pub fn decrypt_bytes_with_keys( bytes: &mut Bytes, enc_keys: &EncKeys ) -> Result<Bytes, CryptrError>
Decrypt a given Bytes directly with given keys
sourcepub fn decrypt_with_password(self, password: &str) -> Result<Bytes, CryptrError>
pub fn decrypt_with_password(self, password: &str) -> Result<Bytes, CryptrError>
Decrypt a value with a given password
sourcepub fn decrypt_bytes_with_password(
bytes: &mut Bytes,
password: &str
) -> Result<Bytes, CryptrError>
pub fn decrypt_bytes_with_password( bytes: &mut Bytes, password: &str ) -> Result<Bytes, CryptrError>
Decrypt a given Bytes directly with given password
sourcepub fn try_from_bytes(bytes: Vec<u8>) -> Result<Self, CryptrError>
pub fn try_from_bytes(bytes: Vec<u8>) -> Result<Self, CryptrError>
Try to build from raw encrypted bytes
sourcepub async fn try_from_file(path: &str) -> Result<Self, CryptrError>
pub async fn try_from_file(path: &str) -> Result<Self, CryptrError>
Try to build from a raw encrypted file
sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Convert self into raw bytes
source§impl EncValue
impl EncValue
sourcepub async fn encrypt_stream(
reader: StreamReader<'_>,
writer: StreamWriter<'_>
) -> Result<(), CryptrError>
pub async fn encrypt_stream( reader: StreamReader<'_>, writer: StreamWriter<'_> ) -> Result<(), CryptrError>
Streaming encryption with the statically initialized encryption keys
Panics
If init() has not been called on valid EncKeys once before
sourcepub async fn encrypt_stream_with_chunk_size(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
chunk_size_kb: ChunkSizeKb
) -> Result<(), CryptrError>
pub async fn encrypt_stream_with_chunk_size( reader: StreamReader<'_>, writer: StreamWriter<'_>, chunk_size_kb: ChunkSizeKb ) -> Result<(), CryptrError>
Streaming encryption with the statically initialized encryption keys and custom chunk size
Panics
If init() has not been called on valid EncKeys once before
sourcepub async fn encrypt_stream_with_key_id(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
enc_key_id: String
) -> Result<(), CryptrError>
pub async fn encrypt_stream_with_key_id( reader: StreamReader<'_>, writer: StreamWriter<'_>, enc_key_id: String ) -> Result<(), CryptrError>
Streaming encryption with a specific Key ID from the statically initialized encryption keys
sourcepub async fn encrypt_stream_with_key(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
enc_key_id: String,
enc_key: Vec<u8>
) -> Result<(), CryptrError>
pub async fn encrypt_stream_with_key( reader: StreamReader<'_>, writer: StreamWriter<'_>, enc_key_id: String, enc_key: Vec<u8> ) -> Result<(), CryptrError>
Streaming encryption with a dynamic key ID and key
sourcepub async fn encrypt_stream_with_password(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
password: &str
) -> Result<(), CryptrError>
pub async fn encrypt_stream_with_password( reader: StreamReader<'_>, writer: StreamWriter<'_>, password: &str ) -> Result<(), CryptrError>
Streaming encryption with password
sourcepub async fn encrypt_stream_with_chunk_size_and_key_id(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
chunk_size_kb: ChunkSizeKb,
enc_key_id: String
) -> Result<(), CryptrError>
pub async fn encrypt_stream_with_chunk_size_and_key_id( reader: StreamReader<'_>, writer: StreamWriter<'_>, chunk_size_kb: ChunkSizeKb, enc_key_id: String ) -> Result<(), CryptrError>
Streaming encryption with a specific Key ID from the statically initialized encryption keys and custom chunk size
sourcepub async fn encrypt_stream_with_chunk_size_and_key(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
chunk_size_kb: ChunkSizeKb,
enc_key_id: String,
enc_key: Vec<u8>
) -> Result<(), CryptrError>
pub async fn encrypt_stream_with_chunk_size_and_key( reader: StreamReader<'_>, writer: StreamWriter<'_>, chunk_size_kb: ChunkSizeKb, enc_key_id: String, enc_key: Vec<u8> ) -> Result<(), CryptrError>
Streaming encryption with a dynamic key ID, key and custom chunk size
sourcepub async fn encrypt_stream_with_chunk_size_and_password(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
chunk_size_kb: ChunkSizeKb,
password: &str
) -> Result<(), CryptrError>
pub async fn encrypt_stream_with_chunk_size_and_password( reader: StreamReader<'_>, writer: StreamWriter<'_>, chunk_size_kb: ChunkSizeKb, password: &str ) -> Result<(), CryptrError>
Streaming encryption with password and custom chunk size
sourcepub async fn decrypt_stream(
reader: StreamReader<'_>,
writer: StreamWriter<'_>
) -> Result<(), CryptrError>
pub async fn decrypt_stream( reader: StreamReader<'_>, writer: StreamWriter<'_> ) -> Result<(), CryptrError>
Streaming decryption with the statically initialized encryption keys
sourcepub async fn decrypt_stream_with_keys(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
enc_keys: &EncKeys
) -> Result<(), CryptrError>
pub async fn decrypt_stream_with_keys( reader: StreamReader<'_>, writer: StreamWriter<'_>, enc_keys: &EncKeys ) -> Result<(), CryptrError>
Streaming decryption with given dynamic encryption keys
sourcepub async fn decrypt_stream_with_password(
reader: StreamReader<'_>,
writer: StreamWriter<'_>,
password: &str
) -> Result<(), CryptrError>
pub async fn decrypt_stream_with_password( reader: StreamReader<'_>, writer: StreamWriter<'_>, password: &str ) -> Result<(), CryptrError>
Streaming decryption with given password