Im creating a chat application and I'm trying to encrypt messages send. I have a function encrypt(arg1,arg2), it takes two arguments and returns an encrypted text. Here I'm trying to emit an object with the function and the handle on the client side
$('#send').on('click', function(){
socket.emit('chat',{
message: encrypt(message.value,key1),
handle: handle.value,
});
here is the server side
socket.on('chat',function(data){
console.log(data.message);
socket.username = data.handle;
io.sockets.emit('chat', data); //data being sent back to all sockets
});
I tried this and every message sent is blank. What is the correct way for doing this? Im using JavaScript,node.js,express
Comments
Post a Comment