encrypt_raw

Function encrypt_raw 

Source
pub fn encrypt_raw(data: &[u8], key: &str) -> Vec<u8> 
Expand description

Encrypt a u8 vector with XXTEA

Note: XXTEA works on 32 bit words. If input is not evenly dividable by four, it will be padded with zeroes. Padding information is lost after the encryption and this needs to be taken into consideration when decrypting messages.

§Arguments

  • data - The data to be encrypted
  • key - encryption key

§Example

let key : &str = "SecretKey";
let data : [u8; 5] = [11, 13, 0, 14, 15];

let encrypted_data = xxtea::encrypt_raw(&data.to_vec(), &key);
// encrypted data will be 8 bytes (3 zeroes appended to the end)
println!("Encrypted data: {:?}", encrypted_data);