diff --git a/index.js b/index.js index c7b0e3e..80a217b 100644 --- a/index.js +++ b/index.js @@ -191,11 +191,13 @@ function make_encryption_key(string) var key = new Object(); // Set the varibles - key.str = string; + key.str = toBuffer(string); key.at = new Object(); key.at.rx = 0; key.at.tx = 0; + console.log("make_encryption_key:", key.str); + // Return the key return key; } @@ -303,8 +305,8 @@ function connect(hostname, port=22068) if(g.sock_new != 0) { - // Split the data by newlines - data = JSON.parse(data.toString()); + // Parse the string + data = JSON.parse(toBytes(data)); // Is this the key if(data.mode == "encryption_key") @@ -314,6 +316,9 @@ function connect(hostname, port=22068) mode: "decrypt", data: data.key })); + + // Set sock new + g.sock_new = 0; } } @@ -322,14 +327,12 @@ function connect(hostname, port=22068) // Decrypt the data data = string_decrypt(g.encryption, data); - // Split the data by newlines - data = bsplit(data, Buffer.from("\n")); + // Convert it from JSON + data = JSON.parse(data); - // Iterate over them - for(var i=0;i