code: function encrypt (input, firstKey = 0xAB) {
    const buf = Buffer.from(input);
    let key = firstKey;
    for (let i = 0; i < buf.length; i++) {
      buf[i] = buf[i] ^ key;
      key = buf[i];
    }
    return buf;
  }
docs: TP-Link Smarthome Crypto
  
  TCP communication includes a 4 byte header, UDP does not.
  @module tplink-smarthome-crypto
   
  Encrypts input where each byte is XOR'd with the previous encrypted byte.
  @alias  module:tplink-smarthome-crypto.encrypt
  @param  {(Buffer|string)} input           Buffer/string to encrypt
  @param  {number} [firstKey=0xAB]
  @return {Buffer}                 encrypted buffer