maskify

1.0.1 • Public • Published

maskify

Mask sensitive data strings and only expose certain parts

Useful to mask credit card numbers, secret tokens or any other data.

npm version Build Status

Install

$ npm install maskify

Usage

import maskify from 'maskify';
 
// Example to mask a standard credit card number
maskify('4556-3646-0793-5616');
// => '4###-####-####-5616'
 
// By default only masks digits
maskify('A1234567BCDEFG89HI');
// => 'A#######BCDEFG89HI'
 
// By default does not mask short credit card numbers
maskify('54321');
// => '54321'
 

API

maskify(string, [options])

Returns a new masked string.

string

Type: string

options

Type: object

maskSymbol

Type: string
Default: #

Symbol to mask the characters with.

matchPattern

Type: regexObj
Default: /^\d+$/

Only mask characters matching the pattern and keep other characters unmasked.

visibleCharsStart

Type: number
Default: 1

Number of characters not to mask at the start of the string (4 ###-####-####)

visibleCharsEnd

Type: number
Default: 4

Number of characters not to mask at the end of the string (###-####-#### 5616).

minChars

Type: number
Default: 6

Minimum characters of input string length to start masking.

License

MIT © André Ruffert

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    60
    • latest

Version History

Package Sidebar

Install

npm i maskify

Weekly Downloads

60

Version

1.0.1

License

MIT

Unpacked Size

4.08 kB

Total Files

7

Last publish

Collaborators

  • andreruffert