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
pub fn encrypt_chacha20( &self, plaintext: &str, _associated_data: Option<&[u8]>, ) -> Result<String>
pub fn decrypt_chacha20( &self, ciphertext: &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 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