How To Integrate Pubnub In As The Secure Messaging Service
Good News! Nosotros've launched an all new Chat Resource Middle.
We recommend checking out our new Chat Resources Eye, which includes overviews, tutorials, and blueprint patterns for edifice and deploying mobile and web chat.
Take me to the Chat Resource Middle →
In this web log post, we'll cover how to build a key commutation system with PubNub, and one time we exercise and so, we'll exist able to ship encrypted messages between users.
Here's what nosotros've covered so far:
- Role 1: Set upwardly a chat application and gave an overview of its architecture.
- Part 3: Walked yous through how to send TLS encrypted chat letters.
- Function Four: How to send self destructing chat letters
- Function Five: Edifice a chatroom UI
This is a v office series on building Babel, an open source chat widget and API congenital with PubNub. Babel allows you to send and receive self destructing, encrypted messages and exchange 1024-bit RSA public keys in a chatroom.
We have a alive working Boom-boom self destructing chat demo here. You can also take a look at the source code on our Babel Github Repository. Now, let's go the tutorial started!
Building a Central Commutation System
Exchanging public keys is a primal component of Babel and developing cocky destructive messages. Once two users have exchanged public keys, they tin can then send encrypted letters to i another.
So how does Babel use PubNub to substitution public keys? Let's walkthrough how you can build your own key commutation organization with PubNub.
Step i: Import the PubNub JavaScript SDK
You lot'll beginning need to sign up for a PubNub account. Once you sign up, you can become your unique PubNub keys in the PubNub Developer Portal. And so, import the PubNub JavaScript SDK and to initialize PubNub with your unique keys, besides equally SSL enabled and withuuid
set to a username that other users will exist able to identify us with..
Step 2: Public Key Sharing
Our next footstep is to get a public central to exist shared. For the purposes of this blog post, nosotros'll just use a random string to substitute for our public central. However, a more realistic public key string would exist something similar the Base64 encoding of an RSA public key.
After we get a public central, nosotros tin can share information technology with the PubNub Presence feature. To practise this, we first subscribe to a PubNub channel and prepare our state
to an object that contains our username and public key.
Integrating PubNub Presence
PubNub Presence allows users to see who is online and offline, and updates in real time every bit users log on and off. After subscribing to a channel, other users will be able to come across our country
with PubNub Presence.
here_now
gets a list of unique user-ids currently subscribed to the aqueduct, the total occupancy of the channel, and too the state
information of all users subscribed to the channel since we set state
to truthful
in our function telephone call.
The data returned past here_now
to the callback will look something like this.
Thus, to get the state
of all the users subscribed to the channel, you tin can loop through the uuids
assortment from the the data returned by here_now
.
Equally you lot can see, exchanging your public keys with PubNub is actually easy! However, nosotros're not done yet. In futurity blog posts we'll become over how to send encrypted letters and self-destructing messages through PubNub.
How To Integrate Pubnub In As The Secure Messaging Service,
Source: https://www.pubnub.com/blog/self-destructing-chat-building-key-exchange-system/
Posted by: harrellgare1973.blogspot.com
0 Response to "How To Integrate Pubnub In As The Secure Messaging Service"
Post a Comment