shadow_crypt_core/v1/
file_ops.rs

1use crate::{
2    errors::HeaderError,
3    v1::{file::EncryptedFile, header_ops},
4};
5
6pub fn get_encrypted_file_from_bytes(bytes: &[u8]) -> Result<EncryptedFile, HeaderError> {
7    let header = header_ops::try_deserialize(bytes)?;
8    let header_length = header.header_length as usize;
9
10    let ciphertext = bytes[header_length..].to_vec();
11
12    Ok(EncryptedFile::new(header, ciphertext))
13}