pub struct EncryptionManager { /* private fields */ }Expand description
对称加密门面。
Implementations§
Source§impl EncryptionManager
impl EncryptionManager
Sourcepub fn new(
registry: Registry<Box<dyn SymmetricCipher>>,
default_identifier: impl Into<String>,
) -> Result<Self>
pub fn new( registry: Registry<Box<dyn SymmetricCipher>>, default_identifier: impl Into<String>, ) -> Result<Self>
default_identifier 必须已注册,否则返回 Error::UnknownIdentifier。
pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>>
pub fn encrypt_with( &self, identifier: &str, plaintext: &[u8], ) -> Result<Vec<u8>>
pub fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>>
pub fn decrypt_with( &self, identifier: &str, ciphertext: &[u8], ) -> Result<Vec<u8>>
pub fn registry(&self) -> &Registry<Box<dyn SymmetricCipher>>
pub fn registry_mut(&mut self) -> &mut Registry<Box<dyn SymmetricCipher>>
pub fn default_identifier(&self) -> &str
pub fn set_default_identifier( &mut self, identifier: impl Into<String>, ) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EncryptionManager
impl !UnwindSafe for EncryptionManager
impl Freeze for EncryptionManager
impl Send for EncryptionManager
impl Sync for EncryptionManager
impl Unpin for EncryptionManager
impl UnsafeUnpin for EncryptionManager
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