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

coverup

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coverup

Conceal a string with asterisks

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.7K
decreased by-19.51%
Maintainers
1
Weekly downloads
 
Created
Source

Coverup.js

Build Status Coverage Status

Conceals a string by converting characters to asterisks (or any other character). Works well for masking credit card numbers, API keys, or any other sensitive info you don't want to show in its entirety. Works in Node.js and browsers.

Note: This library doesn't keep your info secure, it simply prevents users from seeing an entire string when it is displayed. Please make sure you take the correct precautions when dealing with sensitive info in your app.

How to Use

npm install coverup --save
var coverup = require('coverup')

coverup('4242-4242-4242-4242')
//=> *******************

coverup('4242-4242-4242-4242', { char: '%' })
//=> %%%%%%%%%%%%%%%%%%%

coverup('4242-4242-4242-4242', { keepSymbols: true })
//=> ****-****-****-****

coverup('4242-4242-4242-4242', { keepLeft: 1, keepRight: 1, compactTo: 4 })
//=> 4****2

coverup('4242-4242-4242-4242', { keepLeft: 4 })
//=> 4242***************

coverup('4242-4242-4242-4242', { keepRight: 4 })
//=> ***************4242
UMD

You can also access the UMD version by using unpkg. This will create Coverup as a global.

<script src="https://unpkg.com/coverup/coverup.min.js"></script>
<script> Coverup('secret') //=> ****** </script>

API

coverup (value, options)

  • value - The value you want to coverup. If the value specified is not a string, it will be converted to a string.

    Type: any

  • options

    • keepLeft - The number of characters to avoid concealing on the left side of the string.

      Type: integer
      Default: 0

    • keepRight - The number of characters to avoid concealing on the right side of the string.

      Type: integer
      Default: 0

    • compactTo - Compact the concealing character to a defined length. This cannot be used in conjunction with keepSymbols, or an error will be thrown.

      Type: integer
      Default: 0

    • keepSymbols - Whether you want to ignore symbols when concealing. When set to true, only alphanumeric characters will be concealed. This cannot be used in conjunction with compactTo, or an error will be thrown.

      Type: boolean
      Default: false

    • char - The character to use when concealing.

      Type: string
      Default: *

License

MIT © Jason Maurer

Keywords

FAQs

Package last updated on 28 Jun 2017

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