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

random-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-string

Simple Module for generating Random Strings

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
48K
increased by2.6%
Maintainers
1
Weekly downloads
 
Created
Source

random-string

Simple Module for generating Random Strings

Getting Started

Install the module with: npm install random-string

var randomString = require('random-string');
var x = randomString(); // x contains now a random String with the length of 8

Documentation

You can call the randomString-Method with additional options for specifing how long your resulting string should be and which characters to include

// e.g. you want a string with a length of 20
var x = randomString({length: 20});

options

options.length

number - the length of your resulting string (DEFAULT: 8)

options.numeric

boolean - should your resulting string contain numbers (from 0-9) (DEFAULT: true)

options.letters

boolean - should your resulting string contain letters (from a-z, lower and uppercase) (DEFAULT: true)

options.special

boolean - should your resulting string contain any of these special characters (!$%^&*()_+|~-=`{}[]:;<>?,./) (DEFAULT: false)

Examples

// that would be a call with all options (hint: thats a call with all defaults, und the options wouldnt be necessary in that case!)
var x = randomString({
  length: 8,
  numeric: true,
  letters: true,
  special: false
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 0.1.1 do not contain special cars per default

  • 0.1.0 Initial Release

Contributors

  • Bastian "hereandnow" Behrens

License

Copyright (c) 2013 Valiton GmbH Licensed under the MIT license.

Keywords

FAQs

Package last updated on 16 May 2013

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