pub struct EncryptionProvider { /* private fields */ }Expand description
Encryption provider for column-level encryption
Implementations§
Source§impl EncryptionProvider
impl EncryptionProvider
Sourcepub fn new(master_key: &[u8]) -> Result<Self, EncryptionError>
pub fn new(master_key: &[u8]) -> Result<Self, EncryptionError>
Create a new encryption provider with a master key
Sourcepub fn generate_key() -> Vec<u8> ⓘ
pub fn generate_key() -> Vec<u8> ⓘ
Generate a new random encryption key
Sourcepub fn add_key(
&self,
key_id: String,
key: Vec<u8>,
) -> Result<(), EncryptionError>
pub fn add_key( &self, key_id: String, key: Vec<u8>, ) -> Result<(), EncryptionError>
Add a new encryption key for key rotation
Sourcepub fn set_active_key(&self, key_id: String) -> Result<(), EncryptionError>
pub fn set_active_key(&self, key_id: String) -> Result<(), EncryptionError>
Set the active key ID for new encryptions
Sourcepub fn encrypt(
&self,
plaintext: &[u8],
) -> Result<EncryptedData, EncryptionError>
pub fn encrypt( &self, plaintext: &[u8], ) -> Result<EncryptedData, EncryptionError>
Encrypt data using the active key
Sourcepub fn encrypt_with_key(
&self,
key_id: &str,
plaintext: &[u8],
) -> Result<EncryptedData, EncryptionError>
pub fn encrypt_with_key( &self, key_id: &str, plaintext: &[u8], ) -> Result<EncryptedData, EncryptionError>
Encrypt data with a specific key
Sourcepub fn decrypt(
&self,
encrypted: &EncryptedData,
) -> Result<Vec<u8>, EncryptionError>
pub fn decrypt( &self, encrypted: &EncryptedData, ) -> Result<Vec<u8>, EncryptionError>
Decrypt data
Sourcepub fn encrypt_string(&self, plaintext: &str) -> Result<String, EncryptionError>
pub fn encrypt_string(&self, plaintext: &str) -> Result<String, EncryptionError>
Encrypt a string value
Sourcepub fn decrypt_string(
&self,
ciphertext: &str,
) -> Result<String, EncryptionError>
pub fn decrypt_string( &self, ciphertext: &str, ) -> Result<String, EncryptionError>
Decrypt a string value
Sourcepub fn reencrypt(
&self,
encrypted: &EncryptedData,
new_key_id: &str,
) -> Result<EncryptedData, EncryptionError>
pub fn reencrypt( &self, encrypted: &EncryptedData, new_key_id: &str, ) -> Result<EncryptedData, EncryptionError>
Re-encrypt data with a new key (for key rotation)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EncryptionProvider
impl RefUnwindSafe for EncryptionProvider
impl Send for EncryptionProvider
impl Sync for EncryptionProvider
impl Unpin for EncryptionProvider
impl UnwindSafe for EncryptionProvider
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