pub fn encrypt(
    packet: &[u8],
    keys: &HashSet<Keys>
) -> Result<Vec<Vec<u8>>, Crypt4GHError>
Expand description

Computes the encrypted part, using all keys

Given a set of keys and a vector of bytes, it iterates the keys and for every valid key (key.method == 0), it encrypts the packet. It uses chacha20 and poly1305 to encrypt the packet. It returns a set of encrypted segments that represent the packet for every key.

  • packet is a vector of bytes of information to be encrypted
  • keys is a unique collection of keys with key.method == 0