Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var net = require('net');
var themis = require('jsthemis');
comparator = new themis.SecureComparator(new Buffer.from("secret"));
var client = new net.Socket();
client.connect(1337, '127.0.0.1', function() {
console.log('Connected');
client.write(comparator.beginCompare());
});
client.on('data', function(data) {
d = comparator.proceedCompare(data);
if(!comparator.isCompareComplete())
client.write(d);
else{
console.log(comparator.isMatch());
client.destroy();
}
});
var server = net.createServer(function(socket) {
comparator = new themis.SecureComparator(new Buffer.from("secret"));
socket.on('data', function (data) {
d=comparator.proceedCompare(data);
socket.write(d);
if(comparator.isCompareComplete()){
console.log(comparator.isMatch());
socket.destroy();
}
});
});