Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

kevast/kevast-encrypt.js

Repository files navigation

kevast-file.js

Build Status Coverage Status Dependencies Dev Dependencies Package Version Open Issues MIT License

Encryption middleware for kevast.js.

Kevast-gist encrypts data with AES-128-CBC.

For encryption detail, refer to node-forge.

Installation

Node.js

Using yarn

yarn add kevast-encrypt

Using npm

npm install kevast-encrypt

Browser

<script src="https://cdn.jsdelivr.net/npm/kevast-encrypt/dist/kevast-encrypt.min.js"></script>

Usage

const { Kevast } = require('kevast');
const { KevastMemory } = require('kevast-memory');
const { KevastEncrypt } = require('kevast-encrypt');
const assert = require('assert');

(async () => {
  const map = new Map();
  const kevast = new Kevast(new KevastMemory(map));
  kevast.use(new KevastEncrypt(KevastEncrypt.randomString()));
  await kevast.set('key', 'value');
  console.log(map);
  assert(await kevast.get('key') === 'value');
})();