Search code examples
javascriptphpencryptionsocket.iolaravel-5.3

end to end encryption with javascript and php


I'm looking to implement end-to-end encryption for messages sent between users in my Laravel app. I want to encrypt these messages in a way that they are only viewable by the sender and receiver (just like in secure messaging apps like WhatsApp). No one else can read them, including admins or dbas.

How would I go about doing this?

I should also mention that the messages will be sent through the browser to the server by a JavaScript AJAX request and pushed to the other user by Node.js / socket.io setup.


Solution

  • Would be helpful if you have posted some examples that you have tried. Here are the steps that you can follow to achieve it.

    Step 1. You will have to establish a private chat between Client and server. An example can be seen here: Creating a private chat between a key using a node.js and socket.io

    Step 2. Add encryption/decryption logic for the messages at Client side. Here is a logic for the same: https://github.com/sytelus/CryptoJS