Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
randomatic
Advanced tools
Generate randomized strings of a specified length using simple character sequences. The original generate-password.
The randomatic npm package is a utility for generating random strings of various patterns. It can be used to create random and unique strings of a specified length, pattern, or characters, which is useful for generating passwords, identifiers, and other random tokens.
Pattern-based random string generation
Generates a random string of length 10 following the pattern 'Aa0!', where 'A' stands for uppercase letters, 'a' for lowercase letters, '0' for numbers, and '!' for special characters.
randomatic('Aa0!', 10)
Custom character pool
Generates a random string of length 10 using only the characters provided in the 'chars' option, in this case, 'abc123'.
randomatic('?', 10, {chars: 'abc123'})
Masked characters
Generates a random string of length 10 excluding the character 'a' from the possible characters.
randomatic('?', 10, {exclude: 'a'})
Chance is a minimalist generator of random strings, numbers, etc. It is more comprehensive than randomatic, providing a larger set of features for generating random data of various types, not just strings.
Faker is a powerful library for generating massive amounts of fake data, including random strings. It is designed to be easy to use and comprehensive, offering a wide range of data types and locales, which makes it more extensive compared to randomatic.
While not a direct alternative for all of randomatic's functionality, the uuid package is commonly used for generating unique identifiers, which is one of the use cases for randomatic. It provides RFC-compliant UUID generation.
Generate randomized strings of a specified length using simple character sequences. The original generate-password.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save randomatic
var randomize = require('randomatic');
randomize(pattern, length, options);
pattern
{String}: (required) The pattern to use for randomizinglength
{Number}: (optional) The length of the string to generateoptions
{Object}: (optional) See available optionsThe pattern to use for randomizing
Patterns can contain any combination of the below characters, specified in any order.
Example:
To generate a 10-character randomized string using all available characters:
randomize('*', 10);
//=> 'x2_^-5_T[$'
randomize('Aa0!', 10);
//=> 'LV3u~BSGhw'
a
: Lowercase alpha characters (abcdefghijklmnopqrstuvwxyz'
)A
: Uppercase alpha characters (ABCDEFGHIJKLMNOPQRSTUVWXYZ'
)0
: Numeric characters (0123456789'
)!
: Special characters (~!@#$%^&()_+-={}[];\',.
)*
: All characters (all of the above combined)?
: Custom characters (pass a string of custom characters to the options)the length of the string to generate
Examples:
randomize('A', 5)
will generate a 5-character, uppercase, alphabetical, randomized string, e.g. KDJWJ
.randomize('0', 2)
will generate a 2-digit random numberrandomize('0', 3)
will generate a 3-digit random numberrandomize('0', 12)
will generate a 12-digit random numberrandomize('A0', 16)
will generate a 16-character, alpha-numeric randomized stringIf length
is left undefined, the length of the pattern in the first parameter will be used. For example:
randomize('00')
will generate a 2-digit random numberrandomize('000')
will generate a 3-digit random numberrandomize('0000')
will generate a 4-digit random number...randomize('AAAAA')
will generate a 5-character, uppercase alphabetical random string...These are just examples, see the tests for more use cases and examples.
Type: String
Default: undefined
Define a custom string to be randomized.
Example:
randomize('?', 20, {chars: 'jonschlinkert'})
will generate a 20-character randomized string from the letters contained in jonschlinkert
.randomize('?', {chars: 'jonschlinkert'})
will generate a 13-character randomized string from the letters contained in jonschlinkert
.randomize('A', 4)
(whitespace insenstive) would result in randomized 4-digit uppercase letters, like, ZAKH
, UJSL
... etc.randomize('AAAA')
is equivelant to randomize('A', 4)
randomize('AAA0')
and randomize('AA00')
and randomize('A0A0')
are equivelant to randomize('A0', 4)
randomize('aa')
: results in double-digit, randomized, lower-case letters (abcdefghijklmnopqrstuvwxyz
)randomize('AAA')
: results in triple-digit, randomized, upper-case letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ
)randomize('0', 6)
: results in six-digit, randomized numbers (0123456789
)randomize('!', 5)
: results in single-digit randomized, valid non-letter characters (`~!@#$%^&()_+-={}[]randomize('A!a0', 9)
: results in nine-digit, randomized characters (any of the above)The order in which the characters are defined is insignificant.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
You might also be interested in these projects:
Commits | Contributor |
---|---|
48 | jonschlinkert |
2 | realityking |
1 | TrySound |
1 | Drag0s |
1 | paulmillr |
1 | sunknudsen |
1 | faizulhaque-tp |
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on October 19, 2017.
FAQs
Generate randomized strings of a specified length using simple character sequences. The original generate-password.
We found that randomatic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.