So you might be wondering how WhatsApp, telegram type application says that their user’s data is “Encrypted” all across the network.

That means all the messages stored in their database are encrypted, so even if some “third party” try to “tap” the messages while they are on there way to reach there destination, the intercepted message will be in encrypted form.

In this article, I am going to show you how to build a Simple E2E (which is not going to be as secure as Whatsapp uses, but still, it is better than having nothing).

We will be using a single secret key to encrypt and decrypt our messages, thus having symmetric encryption architecture.

Note, Whatsapp uses the Diffie-Helman technique to achieve Asymmetrical encryption, it is one of those techniques which can be used to produce most secure chat applications, if you want to learn more about this, please refer this link.

Working

As shown in the above picture, we will create a secret key that will be stored in frontend (For now, I am storing it in the frontend file itself but for production, you have to save it in the .ENV variables of your server where you have deployed your front-end).

Whenever a user sends the message, we have to encrypt it using aes256 npm package with your secret key. We will repeat the process after receiving the encrypted message, but this time it will be decrypted using the same secret key.

ode

Backend (Node, Express, Socket.io)

Folder Structure

Backend
 |- dummyuser.js
 |- server.js
 |- package.json

#programming #javascript #latest-tech-stories #reactjs #socketio #nodejs #realtime #web-development

Creating Real-Time Chat App using React And Socket.io with E2E Encryption
20.80 GEEK