Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
debug('Payload:', payload);
// Encrypt data
const data = this.device.cipher.encrypt({
data: JSON.stringify(payload)
});
// Create MD5 signature
const md5 = this.device.cipher.md5('data=' + data +
'||lpv=' + this.device.version +
'||' + this.device.key);
// Create byte buffer from hex data
const thisData = Buffer.from(this.device.version + md5 + data);
const buffer = Parser.encode({
data: thisData,
commandByte: '07'
});
// Send request to change status
return new Promise((resolve, reject) => {
this._send(this.device.ip, buffer).then(() => {
resolve(true);
}).catch(err => {
reject(err);
});
});
};