lib/index.js
function encryptWithHeader (input, firstKey = 0xAB) {
  const msgBuf = encrypt(input, firstKey);
  const outBuf = Buffer.alloc(msgBuf.length + 4);
  outBuf.writeUInt32BE(msgBuf.length, 0);
  msgBuf.copy(outBuf, 4);
  return outBuf;
}
function encryptWithHeader (input, firstKey = 0xAB) {
  const msgBuf = encrypt(input, firstKey);
  const outBuf = Buffer.alloc(msgBuf.length + 4);
  outBuf.writeUInt32BE(msgBuf.length, 0);
  msgBuf.copy(outBuf, 4);
  return outBuf;
}
function encryptWithHeader ( input , firstKey = 0xAB ) { const msgBuf = encrypt ( input , firstKey ) ; const outBuf = Buffer . alloc ( msgBuf . length + 4 ) ; outBuf . writeUInt32BE ( msgBuf . length , 0 ) ; msgBuf . copy ( outBuf , 4 ) ; return outBuf ; }
Encrypts input that has a 4 byte big-endian length header;
each byte is XOR'd with the previous encrypted byte.
@alias  module:tplink-smarthome-crypto.encryptWithHeader
@param  {(Buffer|string)} input           Buffer/string to encrypt
@param  {number} [firstKey=0xAB]
@return {Buffer}                 encrypted buffer with header
Encrypts input that has a 4 byte big - endian length header ; each byte is XOR d with the previous encrypted byte .