Skip to main content

Encryptable

Trait Encryptable 

Source
pub trait Encryptable: WriteBytes {
    // Provided methods
    fn encrypt(&mut self, data: &[u8], pfh_version: PFHVersion) -> Result<()> { ... }
    fn encrypt_u32(&mut self, value: u32, second_key: u32) -> Result<()> { ... }
    fn encrypt_string(&mut self, path: &str, second_key: u8) -> Result<()> { ... }
}
Expand description

Trait for encrypting PackFile data.

This trait provides the inverse operations of Decryptable, writing the encrypted data into the implementor.

§Implementation

This trait is automatically implemented for any type that implements WriteBytes.

Provided Methods§

Source

fn encrypt(&mut self, data: &[u8], pfh_version: PFHVersion) -> Result<()>

Encrypts the data of a PackedFile and writes it.

Data is encrypted in 8-byte chunks using the DATA_KEY. Trailing bytes that don’t fill a full chunk are written unencrypted.

§Arguments
  • data - The plain data to encrypt.
  • pfh_version - The version of the Pack the data is for. Determines the width of the position term in the key.
§Errors

Returns an error if writing fails.

Source

fn encrypt_u32(&mut self, value: u32, second_key: u32) -> Result<()>

Encrypts a u32 of a PackedFile’s index entry (size or timestamp) and writes it.

§Arguments
  • value - The plain value to encrypt.
  • second_key - The secondary key, the number of PackedFiles after this one in the index.
§Errors

Returns an error if writing fails.

Source

fn encrypt_string(&mut self, path: &str, second_key: u8) -> Result<()>

Encrypts the path of a PackedFile, including its null terminator, and writes it.

§Arguments
  • path - The plain path to encrypt.
  • second_key - The secondary key, the lowest byte of the PackedFile’s size in the Pack.
§Errors

Returns an error if writing fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§