DEV Community

Message Encryption in JavaScript and PHP

Scott Arciszewski on October 20, 2019

Just for fun, let's encrypt some stuff in client-side JavaScript and have a PHP server decrypt it. Note that this will never replace TLS (HTTPS). ...
Collapse
 
brzuchal profile image
Michał Brzuchalski

Shouldn't sendEncryptedMessage() function send content of encrypted variable in JSON? Currently in example it sends unencrypted message.

Collapse
 
paragoniescott profile image
Scott Arciszewski

Yep! That was a pasto. I originally stored the ciphertext in message then refactored it to make it easier to read.

Collapse
 
nathilia_pierce profile image
Nathilia Pierce

This is great! I'm glad to see libsodium making its way into the JS eco-system.

Collapse
 
eduluz1976 profile image
Eduardo Luz

Nice post.

Collapse
 
rajkumar12992 profile image
Rajkumar

Is there any way to add random key for each request? Because keeping the same key is not secured right?