Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-fpe

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-fpe

Format-preserving encryption implementation

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.7K
increased by10.71%
Maintainers
1
Weekly downloads
 
Created
Source

node-fpe

Build status styled with prettier

Format preserving string substitution encryption

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 substitution cipher algorithm. Read more about the security of this library in the dedicated section below.

Usage

Example:

cipher with default domain ([0-9])

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

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

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

cipher with a custom domain ([A-E])

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

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

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

Options

Options to pass on to node-fpe are:

  • secret: mandatory. a secret used in the underlying hash function.
  • domain: optional. an array of characters used as the FPE domain. default: 0-9 digits

Security

This module is using the term format-preserving encryption, however it is not a proper fpe implementation. It is basically a substitution cipher, you can use it to scramble and de-scramble strings but it is not recommended to use it with anything sensitive as the encryption is weak.

For fpe, there are other libraries available:

Keywords

FAQs

Package last updated on 30 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc