Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreruffert/maskify
πΌ Mask sensitive data strings
https://github.com/andreruffert/maskify
javascript mask nodejs utility
Last synced: 2 months ago
JSON representation
πΌ Mask sensitive data strings
- Host: GitHub
- URL: https://github.com/andreruffert/maskify
- Owner: andreruffert
- Created: 2019-04-30T10:17:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-16T14:01:19.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T11:01:23.037Z (3 months ago)
- Topics: javascript, mask, nodejs, utility
- Language: JavaScript
- Homepage: https://npm.im/maskify
- Size: 117 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# maskify
> Mask sensitive data strings and only expose certain parts
[![CI status](https://github.com/andreruffert/maskify/workflows/CI/badge.svg)](https://github.com/andreruffert/maskify/actions?workflow=CI)
[![npm version](https://img.shields.io/npm/v/maskify.svg)](https://www.npmjs.com/package/maskify)
[![npm downloads](https://img.shields.io/npm/dm/maskify?logo=npm)](https://www.npmjs.com/package/maskify)Useful to mask credit card numbers, secret tokens or any other data.
## Install
```
$ npm install maskify
```## Usage
```js
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](https://andreruffert.com)