node-fpei

1.0.0 • Public • Published

node-fpe

Build Status styled with prettier

Simple format-preserving encryption implementation

In general, format-preserving encryption is a type of encryption such that the output (the ciphertext) is in the same format as the input (the plaintext).

This library uses a simple FPE from a prefix cipher. The method is only useful for a small domains, for example numbers or alphanumeric.

Usage

Example:

cipher with default domain ([0-9]) and default encryption alg (aes-256-cbc):

const fpe = require('node-fpe');
const cipher = fpe({ password: 'secret' });

cipher.encrypt('1234567');
// '4185730'

cipher.decrypt('4185730');
// '1234567'

cipher with custom domain ([A-E]) and default encryption alg (aes-256-cbc):

const fpe = require('node-fpe');
const cipher = fpe({ password: 'secret', domain: ['A', 'B', 'C', 'D', 'E'] });

cipher.encrypt('BEEBEE');
// 'CBBCBB'

cipher.decrypt('CBBCBB');
// 'BEEBEE'

Options

Options to pass on to node-fpe are:

  • password: mandatory. a secret used in the underlying block cipher.
  • algorithm: optional. the underlying block cipher used. similar to the input to node's crypto.createCipher(). default: aes-256-cbc
  • domain: optional. an array of characters used as the FPE domain. default: 0-9 digits

Package Sidebar

Install

npm i node-fpei

Homepage

github.com/

Weekly Downloads

12

Version

1.0.0

License

MIT

Unpacked Size

5.15 kB

Total Files

4

Last publish

Collaborators

  • jeronimobax