2
0

Moved gateway key into configurator

This commit is contained in:
Harald Rietman
2017-06-30 22:02:50 +02:00
parent 34a94a3615
commit 15d1a38dce
4 changed files with 11 additions and 11 deletions

View File

@@ -10,6 +10,7 @@ module.exports = function(RED) {
this.output = config.output;
this.onmsg = config.onmsg;
this.offmsg = config.offmsg;
this.key = this.gateway.key;
var node = this;
var currentToken = "";
@@ -23,11 +24,10 @@ module.exports = function(RED) {
var payload = msg.payload;
if (payload.cmd == "heartbeat" && payload.model == "gateway") {
var key = "c7utmdo2acpzai5b";
var token = payload.token;
if (token) {
var cipher = crypto.createCipheriv('aes128', key, (new Buffer("17996d093d28ddb3ba695a2e6f58562e", "hex")));
var cipher = crypto.createCipheriv('aes128', node.key, (new Buffer("17996d093d28ddb3ba695a2e6f58562e", "hex")));
var encoded_string = cipher.update(token, 'utf8', 'hex');
encoded_string += cipher.final('hex');