Skip to content
/ maskme Public

🦹‍♀️ Replace sensitive string parts by asterisks (fully customizable).

License

Notifications You must be signed in to change notification settings

rimiti/maskme

Repository files navigation

maskme

Build Status Coverage Status MIT license

Description

This module provide a powerful function to hide your sensible data with "lookbehind" regex.

Installation

$ npm install @rimiti/maskme --save

Using this module in other modules

import Maskme from '@rimiti/maskme';
const Maskme = require('@rimiti/maskme').default;

How to use it?

Keep 2 first and 2 last chars (default configuration: offsetLeft: 2, offsetRight: 2):

Maskme("4242424242424242");
// 42************42

Keep 4 first and 4 last chars and customize replacer:

Maskme("4242424242424242", {replaceBy: "x"});
// 42xxxxxxxxxxxx42

Kepp 2 last chars:

Maskme("4242424242424242", {offsetLeft: 0,});
// **************42

Keep 2 first chars:

Maskme("4242424242424242", {offsetRight: 0});
// 42**************

Hide all chars:

Maskme("4242424242424242", {offsetRight: 0, offsetLeft: 0});
// ****************

Keep 6 first and 5 last chars:

Maskme("4242424242424242", {offsetLeft: 6, offsetRight: 5});
// 424242*****24242

Hide nothing:

Maskme("4242424242424242", {offsetLeft: 30, offsetRight: 40});
// 4242424242424242

License

MIT © Dimitri DO BAIRRO