pub struct ConfigEncryption { /* private fields */ }Expand description
Configuration encryptor: performs symmetric encryption on sensitive configuration values using XOR + Base64.
Applicable scenarios: database passwords, API keys, and other sensitive
configuration should not be stored in plaintext in configuration files.
Encryption format: ENC(base64(xor(plaintext, key)))
Implementations§
Source§impl ConfigEncryption
impl ConfigEncryption
pub fn new(key: impl Into<String>) -> Self
Sourcepub fn encrypt(&self, plaintext: &str) -> String
pub fn encrypt(&self, plaintext: &str) -> String
Encrypt plaintext, returning an ENC(base64) formatted string
Sourcepub fn decrypt(&self, ciphertext: &str) -> Result<String, String>
pub fn decrypt(&self, ciphertext: &str) -> Result<String, String>
Decrypt an ENC(base64) formatted string, returning the plaintext
Sourcepub fn is_encrypted(value: &str) -> bool
pub fn is_encrypted(value: &str) -> bool
Check whether a value is encrypted (starts with ENC( )
Auto Trait Implementations§
impl Freeze for ConfigEncryption
impl RefUnwindSafe for ConfigEncryption
impl Send for ConfigEncryption
impl Sync for ConfigEncryption
impl Unpin for ConfigEncryption
impl UnsafeUnpin for ConfigEncryption
impl UnwindSafe for ConfigEncryption
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