pub struct MessageEncryptor { /* private fields */ }Expand description
Encrypts messages using AES-256-GCM.
Implementations§
Source§impl MessageEncryptor
impl MessageEncryptor
Sourcepub fn new(secret: &[u8]) -> Result<Self, EncryptorError>
pub fn new(secret: &[u8]) -> Result<Self, EncryptorError>
Creates a new encryptor from a 32-byte secret.
Sourcepub fn encrypt_and_sign(&self, data: &[u8]) -> Result<String, EncryptorError>
pub fn encrypt_and_sign(&self, data: &[u8]) -> Result<String, EncryptorError>
Encrypts and authenticates raw bytes.
Sourcepub fn encrypt_and_sign_with_purpose(
&self,
data: &[u8],
purpose: &str,
expires_at: Option<DateTime<Utc>>,
) -> Result<String, EncryptorError>
pub fn encrypt_and_sign_with_purpose( &self, data: &[u8], purpose: &str, expires_at: Option<DateTime<Utc>>, ) -> Result<String, EncryptorError>
Encrypts and authenticates raw bytes with purpose confinement and optional expiration.
Sourcepub fn decrypt_and_verify(
&self,
encrypted_message: &str,
) -> Result<Vec<u8>, EncryptorError>
pub fn decrypt_and_verify( &self, encrypted_message: &str, ) -> Result<Vec<u8>, EncryptorError>
Decrypts and verifies an encrypted message.
Sourcepub fn decrypt_and_verify_with_purpose(
&self,
encrypted_message: &str,
purpose: &str,
) -> Result<Vec<u8>, EncryptorError>
pub fn decrypt_and_verify_with_purpose( &self, encrypted_message: &str, purpose: &str, ) -> Result<Vec<u8>, EncryptorError>
Decrypts and verifies an encrypted message for a specific purpose.
Auto Trait Implementations§
impl Freeze for MessageEncryptor
impl RefUnwindSafe for MessageEncryptor
impl Send for MessageEncryptor
impl Sync for MessageEncryptor
impl Unpin for MessageEncryptor
impl UnsafeUnpin for MessageEncryptor
impl UnwindSafe for MessageEncryptor
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