Skip to content

Instantly share code, notes, and snippets.

View kasparsb's full-sized avatar
Checking

Kaspars kasparsb

Checking
View GitHub Profile
@paragonie-scott
paragonie-scott / js-php-encrypt.md
Last active September 14, 2022 22:04
String Encryption in JavaScript and PHP

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).

JavaScript Encryption with Sodium-Plus

You'll want the latest release of sodium-plus for this. (As of this writing, it's version 0.4.0.)

<script
  src="/static/js/sodium-plus.min.js"
 integrity="sha384-lv7SVE0eb0bXA3fgK6PwlhViiUwG6tBuMAhS8XX7RvBvyRcdEdJ8HKtFgs4vHTUh"