Skip to content

somanwal/node-fpe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Format-preserving encryption implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%