added encrypt and decrypt function for XOR encoding/decoding of packet data