0.2.0 • Published 8 years ago

random-string v0.2.0

Weekly downloads
25,466
License
-
Repository
github
Last release
8 years ago

random-string

Simple Module for generating Random Strings

random-string

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)

options.exclude

array - removes characters from resulting string Note: Lowercase letters will not remove uppercase letters

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,
  exclude: ['a', 'b', '1']
});

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.2.0 introduce exclude-option

  • 0.1.2 fix characterset (#2)

  • 0.1.1 do not contain special cars per default

  • 0.1.0 Initial Release

Contributors

  • Bastian "hereandnow" Behrens
  • Baran "bjskistad" Skistad

License

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

xlcoreservicedev_nativeapirifo-library-providersegg-poppy-api-framework@tigojs/api-request-signpg-api-servercleverstack-dialer@everything-registry/sub-chunk-2528weixinpay-sdkworkzone-chat-sdkwsy-form-buildersupabotbasestatus-aggregatorthirdthird.corethird.kit@conclurer/edel-inputs@canner/pay2gojslapanoid-react-youtubereact-rcstringoverflowspaceholderu-wave-api-v1u-wave-coreu-wave-http-apitiny-simple-peertodos-term@asp2131/rn-anime-sprite@boateo6/cachexprtvue-qn-md-editorwebsite-renderunique-classname-generatorupfosurl-encryptor@huddle01/huddle01-client@forlike/common@infinitebrahmanuniverse/nolb-random-s@lamhotsimamora/random-string@lunde-cloud/create-migration@evolvus/evolvus-charges-billing@khulnasoft/release@poppies/egg-poppy-api-framework@nstaldev/react-core@opentribe/api_group@pallad/containermy-user-mongomimemessagemk-infrastructure-frontmk-bass-uiozserverobfusoembed-alloctopass-client-sdkrsdrawerrn-animated-sprite-matrixreact-messenger-checkbox-pluginreact-native-animated-spritereact-native-animated-sprite-plusreleaseappsreleaserename-randompwp-clireact-native-keyri-sdkseneca-jwtnode-periodicnodeframenodsqlnode-weixin-menu-convertorpodauthpodauth2plug-auth-serverrandom-globalprotooqrtc-web-sdkreact-qn-mdsimetric-store-pluginslipwayhoodie-standalone-storehttpismh5-tutorapphead-masterhapi-couchdb-storelsrtcmasekubernetes-health-checkmaycur-infrastructure-h5-front@tigojs/api-sign@teamtagevo/evolvus-charges-billing@substrate-system/tiny-simple-peeralpha-dicalipay_create_obj@zombiec0rn/zombie-node-format@zombiec0rn/zombie-service-format@zombiec0rn/zombie-swarm-cliaab-test-dataacconfigcallable-data-objectschurchillcccf
0.2.0

8 years ago

0.1.2

11 years ago

0.1.1

12 years ago

0.1.0

12 years ago