shadow-crypt-core 1.0.7

Core types and deterministic operations for shadow-crypt
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::{
    errors::HeaderError,
    v1::{file::EncryptedFile, header_ops},
};

pub fn get_encrypted_file_from_bytes(bytes: &[u8]) -> Result<EncryptedFile, HeaderError> {
    let header = header_ops::try_deserialize(bytes)?;
    let header_length = header.header_length as usize;

    let ciphertext = bytes[header_length..].to_vec();

    Ok(EncryptedFile::new(header, ciphertext))
}