@47ng/simple-e2ee

Simple end-to-end encryption for web apps. Inspired from Excalidraw and Firefox Send (RIP).
How it works
You encrypt your data in the browser, send the encrypted data
to a server, and use the hash part of the URL (which never
hits the server) to share the key with someone else.
On the other side, the recipient obtains the key from the URL,
the payload from the server and decrypts the data.
This library does not handle any of the server upload/download
side, it's up to you. It only deals with encryption, decryption
and moving keys in and out of URLs.
Installation
$ yarn add @47ng/simple-e2ee
# or
$ npm i @47ng/simple-e2ee
Usage
import {
encrypt,
decrypt,
applyKeyToURL,
getKeyFromURL,
generateKey
} from '@47ng/simple-e2ee'
const { payload, key } = encrypt(
"whatever you want, as long as it's JSON-serialisable"
)
const shareURL = applyKeyToURL(key)
const shareURL = applyKeyToURL(key, `https://example.com/share/${id}`)
const key = getKeyFromURL()
const message = decrypt(payload, key)
const key = getKeyFromURL(
`https://example.com/share/foo#KatLceVEOM2znzX_FGPKu6Zz1adWkhlq9b2R9WRjUsM=`
)
const payload = encrypt('some more data', key)
const key = generateKey()
License
MIT - Made with ❤️ by François Best.
Using this package at work ? Sponsor me to help with support and maintenance.