@47ng/simple-e2ee 中文文档教程

发布于 4年前 浏览 24 项目主页 更新于 3年前

@47ng/simple-e2ee

NPM麻省理工学院许可证持续集成覆盖状态Dependabot 状态

Web 应用程序的简单端到端加密。 灵感来自 ExcalidrawFirefox Send (RIP)。

How it works

您在浏览器中加密您的数据,发送加密数据 到服务器,并使用 URL 的散列部分(从不 点击服务器)与其他人共享密钥。

另一方面,接收者从 URL 中获取密钥, 来自服务器的有效负载并解密数据。

该库不处理任何服务器上传/下载 边,就看你的了。 它只处理加密,解密 并将键移入和移出 URL。

Installation

$ yarn add @47ng/simple-e2ee
# or
$ npm i @47ng/simple-e2ee

Usage

import {
  encrypt,
  decrypt,
  applyKeyToURL,
  getKeyFromURL,
  generateKey
} from '@47ng/simple-e2ee'

// Before sending data to the server, encrypt it:
const { payload, key } = encrypt(
  "whatever you want, as long as it's JSON-serialisable"
)

// Upload `payload` to the server
// Stick the key onto the current URL:
const shareURL = applyKeyToURL(key)

// Optionally, apply the key to another URL
// (example, with an ID returned from the server):
const shareURL = applyKeyToURL(key, `https://example.com/share/${id}`)

// On the other side, get the key from the current URL,
// and the payload from the server:
const key = getKeyFromURL()
const message = decrypt(payload, key)

// Optionally, obtain the key from any URL:
const key = getKeyFromURL(
  `https://example.com/share/foo#KatLceVEOM2znzX_FGPKu6Zz1adWkhlq9b2R9WRjUsM=`
)

// Encrypt related pieces of content with the same key:
const payload = encrypt('some more data', key)

// Generate a key for later use:
const key = generateKey()

License

MIT - 用 ❤️ 制作,作者 弗朗索瓦·贝斯特

在工作中使用这个包? 赞助我以帮助支持和维护。

@47ng/simple-e2ee

NPMMIT LicenseContinuous IntegrationCoverage StatusDependabot Status

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'

// Before sending data to the server, encrypt it:
const { payload, key } = encrypt(
  "whatever you want, as long as it's JSON-serialisable"
)

// Upload `payload` to the server
// Stick the key onto the current URL:
const shareURL = applyKeyToURL(key)

// Optionally, apply the key to another URL
// (example, with an ID returned from the server):
const shareURL = applyKeyToURL(key, `https://example.com/share/${id}`)

// On the other side, get the key from the current URL,
// and the payload from the server:
const key = getKeyFromURL()
const message = decrypt(payload, key)

// Optionally, obtain the key from any URL:
const key = getKeyFromURL(
  `https://example.com/share/foo#KatLceVEOM2znzX_FGPKu6Zz1adWkhlq9b2R9WRjUsM=`
)

// Encrypt related pieces of content with the same key:
const payload = encrypt('some more data', key)

// Generate a key for later use:
const key = generateKey()

License

MIT - Made with ❤️ by François Best.

Using this package at work ? Sponsor me to help with support and maintenance.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文