pub struct EncryptedFile { /* private fields */ }Expand description
Represents a complete encrypted file with header and content
Implementations§
Source§impl EncryptedFile
impl EncryptedFile
pub fn new(header: FileHeader, ciphertext: Vec<u8>) -> Self
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, HeaderError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, HeaderError>
Parses a serialized v1 file into its header and content ciphertext.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serializes the complete file (header followed by content ciphertext).
Sourcepub fn decrypt(&self, key: &SecureKey) -> Result<PlaintextFile, FileError>
pub fn decrypt(&self, key: &SecureKey) -> Result<PlaintextFile, FileError>
Decrypts the filename and content. v1 has no header authentication, so only the AEAD tags of the two ciphertexts are verified.
pub fn header(&self) -> &FileHeader
pub fn ciphertext(&self) -> &[u8] ⓘ
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EncryptedFile
impl RefUnwindSafe for EncryptedFile
impl Send for EncryptedFile
impl Sync for EncryptedFile
impl Unpin for EncryptedFile
impl UnsafeUnpin for EncryptedFile
impl UnwindSafe for EncryptedFile
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