pub struct EncryptionKey { /* private fields */ }Expand description
Cryptographic key for encryption operations
Implementations§
Source§impl EncryptionKey
impl EncryptionKey
Sourcepub fn new(algorithm: EncryptionAlgorithm, key_data: Vec<u8>) -> Result<Self>
pub fn new(algorithm: EncryptionAlgorithm, key_data: Vec<u8>) -> Result<Self>
Create a new encryption key from raw bytes
Sourcepub fn from_password_pbkdf2(
password: &str,
salt: Option<&[u8]>,
algorithm: EncryptionAlgorithm,
) -> Result<Self>
pub fn from_password_pbkdf2( password: &str, salt: Option<&[u8]>, algorithm: EncryptionAlgorithm, ) -> Result<Self>
Derive a key from a password using PBKDF2
Sourcepub fn from_password_argon2(
password: &str,
salt: Option<&[u8]>,
algorithm: EncryptionAlgorithm,
) -> Result<Self>
pub fn from_password_argon2( password: &str, salt: Option<&[u8]>, algorithm: EncryptionAlgorithm, ) -> Result<Self>
Derive a key from a password using Argon2
Sourcepub fn encrypt(
&self,
plaintext: &str,
associated_data: Option<&[u8]>,
) -> Result<String>
pub fn encrypt( &self, plaintext: &str, associated_data: Option<&[u8]>, ) -> Result<String>
Encrypt plaintext data
Sourcepub fn decrypt(
&self,
ciphertext: &str,
associated_data: Option<&[u8]>,
) -> Result<String>
pub fn decrypt( &self, ciphertext: &str, associated_data: Option<&[u8]>, ) -> Result<String>
Decrypt ciphertext data
Sourcepub fn encrypt_chacha20(
&self,
plaintext: &str,
_associated_data: Option<&[u8]>,
) -> Result<String>
pub fn encrypt_chacha20( &self, plaintext: &str, _associated_data: Option<&[u8]>, ) -> Result<String>
Auto Trait Implementations§
impl Freeze for EncryptionKey
impl RefUnwindSafe for EncryptionKey
impl Send for EncryptionKey
impl Sync for EncryptionKey
impl Unpin for EncryptionKey
impl UnsafeUnpin for EncryptionKey
impl UnwindSafe for EncryptionKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more