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,.oggor.m4afile.key- Encryption key string.
§Returns
- Encrypted
Vec<u8>if the key is valid. - [
Error] otherwise.
§Errors
Error::InvalidKeyLength- if key’s length is not 32 bytes.Error::KeyNotSet– if key initialization fails.