secret-obfuscator

Replaces secrets in strings with "***".

Usage no npm install needed!

<script type="module">
  import secretObfuscator from 'https://cdn.skypack.dev/secret-obfuscator';
</script>

README

npm version

Secret Obfuscator

Replaces secrets in strings with "***".

Installation

npm install --save secret-obfuscator

or available on JSDelivr at "https://cdn.jsdelivr.net/npm/secret-obfuscator@1".

Usage

import { Obfuscator } from 'secret-obfuscator';

const obfuscator = new Obfuscator({
  secrets: ['abc', 'def', 'efg'],
  replacement: '***', // optional
});

obfuscator.obfuscate('This is a secret: abc');
// => This is a secret: ***
obfuscator.obfuscate('These are some secrets: abc def');
// => These are some secrets: *** ***
obfuscator.obfuscate('This is a mix of overlapping secrets: abcdefg');
// => This is a mix of overlapping secrets: ***