pub struct IpcCipher { /* private fields */ }Expand description
Encrypted message format: [nonce (12 bytes)][ciphertext (variable)][auth tag (16 bytes, included in ciphertext)]
Implementations§
Source§impl IpcCipher
impl IpcCipher
Sourcepub fn from_session_token(token: &str) -> Self
pub fn from_session_token(token: &str) -> Self
Create a new cipher from a session token
The session token is hashed with SHA-256 to derive the encryption key. This ensures a consistent 256-bit key regardless of token length.
Sourcepub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>>
pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>>
Encrypt a message
Returns the encrypted message with nonce prepended. Format: [nonce (12 bytes)][ciphertext + auth tag]
Sourcepub fn decrypt(&self, encrypted: &[u8]) -> Result<Vec<u8>>
pub fn decrypt(&self, encrypted: &[u8]) -> Result<Vec<u8>>
Decrypt a message
Expects format: [nonce (12 bytes)][ciphertext + auth tag]
Sourcepub fn encrypt_string(&self, plaintext: &str) -> Result<String>
pub fn encrypt_string(&self, plaintext: &str) -> Result<String>
Encrypt a string message to base64
Convenient method for encrypting string messages.
Sourcepub fn decrypt_string(&self, encrypted_b64: &str) -> Result<String>
pub fn decrypt_string(&self, encrypted_b64: &str) -> Result<String>
Decrypt a base64 message to string
Convenient method for decrypting string messages.
Auto Trait Implementations§
impl Freeze for IpcCipher
impl RefUnwindSafe for IpcCipher
impl Send for IpcCipher
impl Sync for IpcCipher
impl Unpin for IpcCipher
impl UnsafeUnpin for IpcCipher
impl UnwindSafe for IpcCipher
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