encrypt

Function encrypt 

Source
pub fn encrypt(file_content: &[u8], key: &str) -> Result<Vec<u8>, Error>
Expand description

Encrypts file content using a key string and a temporary Decrypter instance.

This is a convenience wrapper around Decrypter::encrypt. A new Decrypter is created internally, and the key is set from the provided string.

This function copies the file contents and returns an encrypted Vec<u8>. The output includes the RPG Maker encryption header (RPGM_HEADER).

If you want to avoid copying, use encrypt_in_place instead.

§Arguments

  • file_content - The data of .png, .ogg or .m4a file.
  • key - Encryption key string.

§Returns

  • Encrypted Vec<u8> if the key is valid.
  • [Error] otherwise.

§Errors