pub struct SecretCipher { /* private fields */ }Expand description
Represents a cipher for encrypting and decrypting secrets.
Implementations§
Source§impl SecretCipher
impl SecretCipher
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SecretCipher instance with a randomly generated salt.
§Returns
The newly created SecretCipher instance.
Sourcepub fn encrypt_secret(
&self,
secret: &str,
key_str: &str,
) -> Result<(String, String), Box<dyn Error>>
pub fn encrypt_secret( &self, secret: &str, key_str: &str, ) -> Result<(String, String), Box<dyn Error>>
Sourcepub fn decrypt_secret(
&self,
ciphertext_b91: &str,
nonce_b91: &str,
key_str: &str,
) -> Result<String, Box<dyn Error>>
pub fn decrypt_secret( &self, ciphertext_b91: &str, nonce_b91: &str, key_str: &str, ) -> Result<String, Box<dyn Error>>
Decrypts the provided ciphertext using the derived key and random nonce.
§Parameters
ciphertext_b64: The base91-encoded ciphertext to decrypt.nonce_b91: The base91-encoded nonce used for decryption.key_str: The password used for decryption.
§Returns
A result containing the decrypted plaintext as a string, or an error if the operation failed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecretCipher
impl RefUnwindSafe for SecretCipher
impl Send for SecretCipher
impl Sync for SecretCipher
impl Unpin for SecretCipher
impl UnsafeUnpin for SecretCipher
impl UnwindSafe for SecretCipher
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