{"id":13524335,"url":"https://github.com/jonschlinkert/randomatic","last_synced_at":"2025-04-08T09:09:48.470Z","repository":{"id":12952692,"uuid":"15630862","full_name":"jonschlinkert/randomatic","owner":"jonschlinkert","description":"Easily generate random strings like passwords, with simple options for specifying a length and for using patterns of numeric, alpha-numeric, alphabetical, special or custom characters. (the original \"generate-password\")","archived":false,"fork":false,"pushed_at":"2023-07-28T08:13:47.000Z","size":98,"stargazers_count":183,"open_issues_count":7,"forks_count":25,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-18T00:11:32.823Z","etag":null,"topics":["characters","digit","generate-password","javascript","nodejs","password","random","random-characters","randomize","repeat"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-01-04T11:19:48.000Z","updated_at":"2025-02-22T20:30:14.000Z","dependencies_parsed_at":"2022-07-15T13:24:30.743Z","dependency_job_id":"959b7041-780f-4634-9479-a6431ab3cd99","html_url":"https://github.com/jonschlinkert/randomatic","commit_stats":{"total_commits":69,"total_committers":14,"mean_commits":4.928571428571429,"dds":0.4347826086956522,"last_synced_commit":"6c40cd0e969a93c2d8843f2c532e6e5d18350b52"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frandomatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frandomatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frandomatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frandomatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/randomatic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245252331,"owners_count":20585013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["characters","digit","generate-password","javascript","nodejs","password","random","random-characters","randomize","repeat"],"created_at":"2024-08-01T06:01:09.091Z","updated_at":"2025-03-25T03:20:43.211Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","readme":"# randomatic [![NPM version](https://img.shields.io/npm/v/randomatic.svg?style=flat)](https://www.npmjs.com/package/randomatic) [![NPM monthly downloads](https://img.shields.io/npm/dm/randomatic.svg?style=flat)](https://npmjs.org/package/randomatic) [![NPM total downloads](https://img.shields.io/npm/dt/randomatic.svg?style=flat)](https://npmjs.org/package/randomatic) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/randomatic.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/randomatic)\n\n\u003e Generate randomized strings of a specified length using simple character sequences. The original generate-password.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save randomatic\n```\n\n## Usage\n\n```js\nvar randomize = require('randomatic');\n```\n\n## API\n\n```js\nrandomize(pattern, length, options);\nrandomize.isCrypto;\n```\n\n* `pattern` **{String}**: (required) The pattern to use for randomizing\n* `length` **{Number}**: (optional) The length of the string to generate\n* `options` **{Object}**: (optional) See available [options](#options)\n* `randomize.isCrypto` will be `true` when a cryptographically secure function is being used to generate random numbers. The value will be `false` when the function in use is `Math.random`.\n\n### pattern\n\n\u003e The pattern to use for randomizing\n\nPatterns can contain any combination of the below characters, specified in any order.\n\n**Example:**\n\nTo generate a 10-character randomized string using all available characters:\n\n```js\nrandomize('*', 10);\n//=\u003e 'x2_^-5_T[$'\n\nrandomize('Aa0!', 10);\n//=\u003e 'LV3u~BSGhw'\n```\n\n* `a`: Lowercase alpha characters (`abcdefghijklmnopqrstuvwxyz'`)\n* `A`: Uppercase alpha characters (`ABCDEFGHIJKLMNOPQRSTUVWXYZ'`)\n* `0`: Numeric characters (`0123456789'`)\n* `!`: Special characters (`~!@#$%^\u0026()_+-={}[];\\',.`)\n* `*`: All characters (all of the above combined)\n* `?`: Custom characters (pass a string of custom characters to the options)\n\n### length\n\n\u003e The length of the string to generate\n\n**Examples:**\n\n* `randomize('A', 5)` will generate a 5-character, uppercase, alphabetical, randomized string, e.g. `KDJWJ`.\n* `randomize('0', 2)` will generate a 2-digit random number\n* `randomize('0', 3)` will generate a 3-digit random number\n* `randomize('0', 12)` will generate a 12-digit random number\n* `randomize('A0', 16)` will generate a 16-character, alpha-numeric randomized string\n\nIf `length` is left undefined, the length of the pattern in the first parameter will be used. For example:\n\n* `randomize('00')` will generate a 2-digit random number\n* `randomize('000')` will generate a 3-digit random number\n* `randomize('0000')` will generate a 4-digit random number...\n* `randomize('AAAAA')` will generate a 5-character, uppercase alphabetical random string...\n\nThese are just examples, [see the tests](./test.js) for more use cases and examples.\n\n## options\n\n\u003e These are options that can be passed as the third argument.\n\n#### chars\n\nType: `String`\n\nDefault: `undefined`\n\nDefine a custom string to be randomized.\n\n**Example:**\n\n* `randomize('?', 20, {chars: 'jonschlinkert'})` will generate a 20-character randomized string from the letters contained in `jonschlinkert`.\n* `randomize('?', {chars: 'jonschlinkert'})` will generate a 13-character randomized string from the letters contained in `jonschlinkert`.\n\n#### exclude\n\nType: `String|Array`\n\nDefault: `undefined`\n\nSpecify a string or array of characters can are excluded from the possible characters used to generate the randomized string.\n\n**Example:**\n\n* `randomize('*', 20, { exclude: '0oOiIlL1' })` will generate a 20-character randomized string using all of possible characters except for `0oOiIlL1`.\n\n## Usage Examples\n\n* `randomize('A', 4)` (_whitespace insensitive_) would result in randomized 4-digit uppercase letters, like, `ZAKH`, `UJSL`... etc.\n* `randomize('AAAA')` is equivalent to `randomize('A', 4)`\n* `randomize('AAA0')` and `randomize('AA00')` and `randomize('A0A0')` are equivalent to `randomize('A0', 4)`\n* `randomize('aa')`: results in double-digit, randomized, lower-case letters (`abcdefghijklmnopqrstuvwxyz`)\n* `randomize('AAA')`: results in triple-digit, randomized, upper-case letters (`ABCDEFGHIJKLMNOPQRSTUVWXYZ`)\n* `randomize('0', 6)`: results in six-digit, randomized numbers (`0123456789`)\n* `randomize('!', 5)`: results in single-digit randomized, _valid_ non-letter characters (`~!@#$%^\u0026()_+-={}[]\n* `randomize('A!a0', 9)`: results in nine-digit, randomized characters (any of the above)\n\n_The order in which the characters are defined is insignificant._\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning 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:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [pad-left](https://www.npmjs.com/package/pad-left): Left pad a string with zeros or a specified string. Fastest implementation. | [homepage](https://github.com/jonschlinkert/pad-left \"Left pad a string with zeros or a specified string. Fastest implementation.\")\n* [pad-right](https://www.npmjs.com/package/pad-right): Right pad a string with zeros or a specified string. Fastest implementation. | [homepage](https://github.com/jonschlinkert/pad-right \"Right pad a string with zeros or a specified string. Fastest implementation.\")\n* [repeat-string](https://www.npmjs.com/package/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string. | [homepage](https://github.com/jonschlinkert/repeat-string \"Repeat the given string n times. Fastest implementation for repeating a string.\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 56 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 6  | [doowb](https://github.com/doowb) |  \n| 4  | [kivlor](https://github.com/kivlor) |  \n| 2  | [realityking](https://github.com/realityking) |  \n| 2  | [ywpark1](https://github.com/ywpark1) |  \n| 1  | [TrySound](https://github.com/TrySound) |  \n| 1  | [drag0s](https://github.com/drag0s) |  \n| 1  | [paulmillr](https://github.com/paulmillr) |  \n| 1  | [sunknudsen](https://github.com/sunknudsen) |  \n| 1  | [faizulhaque-tp](https://github.com/faizulhaque-tp) |  \n| 1  | [michaelrhodes](https://github.com/michaelrhodes) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on October 23, 2018._\n","funding_links":[],"categories":["JavaScript","Repository"],"sub_categories":["Text/String"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Frandomatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Frandomatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Frandomatic/lists"}