Skip to content

richardschneider/secure-string

Repository files navigation

secure-string

Travis build status Coverage Status npm version semantic-release

Text that should be kept confidential

The change log is automatically produced with the help of semantic-release.

Features

  • The text is stored in an encrypted buffer
  • The plain text is only available in a callback
  • Prompting the user for a secure string

Getting started

secure-string is available for Node.js and the browser. Most modern browsers are supported. If you want to know if your browser is compatible, run the online test suite.

Install with npm

> npm install secure-string --save

Usage

const SecureString = require('secure-string')

const password = new SecureString()
password.appendCodePoint(0x41)
password.value(plainText => {
  console.log('the passowrd is', plainText.toString())
})

See the spec for more examples.

Ask

SecureString.ask prompts the user for some data

const SecureString = require('secure-string')

SecureString.ask('password', (err, answer) => {
  if (err) return console.log(err)
  answer.value(plainText => {
    console.log('the passowrd is', plainText.toString())
  })
})

Browser

Include the package from the unpkg CDN

<script src="https://unpkg.com/secure-string/dist/bundle.min"></script>

This creates SecureString as a global object, or define it if you are using AMD.

License

The MIT license.

Copyright © 2017 Richard Schneider ([email protected])

About

Text that should be kept confidential

Resources

License

Stars

Watchers

Forks

Packages

No packages published