catbox-crypto

Ephemeral encryption layer for catbox cache strategy engines.

Usage no npm install needed!

<script type="module">
  import catboxCrypto from 'https://cdn.skypack.dev/catbox-crypto';
</script>

README

catbox-crypto

Ephemeral encryption layer for catbox cache strategy engines.

Extends any catbox caching engine to automatically encrypt values stored in the cache using random keys. Uses catbox-memory by default.

Options

  • options - an object with the following keys:
    • algorithm - cipher algorithm to use
      • Default: 'aes-128-cbc'
      • see $ openssl list-public-key-algorithms for list of supported algorithms
    • keySize - cipher key size in bytes
      • Default: 16
    • ivSize - cipher initialization vector size in bytes
      • Default: 16
    • engine - is an object, or function detailing the catbox cache strategy to extend
    • engineOptions - the cache strategy configuration object

Example

var Catbox = require('catbox');

var options = {
  algorithm: 'aes-256-cbc',
  keySize: 32,
  ivSize: 16,
  engine: 'catbox-memory',
  engineOptions: {
    maxByteSize: 209715200
  }
};

var client = new Catbox.Client(require('catbox-crypto'), options);

var key = { 
  segment: 'test',
  id: 'test'
};

client.start(function () {
  client.set(key, 0xbeef, 1000, function (err) { ...  });
});