{"name":"crypto-random-string","version":"3.1.0","description":"Generate a cryptographically strong random string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-random-string.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["random","string","text","id","identifier","slug","salt","pin","crypto","strong","secure","hex","secret","protect"],"dependencies":{"type-fest":"^0.8.1"},"devDependencies":{"ava":"^2.1.0","tsd":"^0.11.0","xo":"^0.25.3"},"gitHead":"9f4539975027bf6e8f2478b5ed7ed47562a65522","bugs":{"url":"https://github.com/sindresorhus/crypto-random-string/issues"},"homepage":"https://github.com/sindresorhus/crypto-random-string#readme","_id":"crypto-random-string@3.1.0","_nodeVersion":"10.17.0","_npmVersion":"6.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-Tip3yGB+bA7B0W8E4K4mNf2rZhu5r2G5Tb89/utEl5tP1QuLjTF/S9a1b8ifDrR4ORc9Utf6tscpSEtBY3YcPQ==","shasum":"0368382de82e914179ad2ca9c7a788e260184bae","tarball":"http://registry-npm.ywwl.com/crypto-random-string/download/crypto-random-string-3.1.0.tgz","fileCount":5,"unpackedSize":8927,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeGsmLCRA9TVsSAnZWagAANAkP/iEbhI6CZ9jgxHEj/MpE\nFWCnW8oQDKW3PnXLts3LtPf3GHi+BVyFVZpuNoOhTZ2Ddm43nlgs+CJE7Wzo\nPo2BsIXtJwSmm1TCDyNq5etzEX5AOVIRr2P3HpzitgVSSQO6fXj6JJ6NI5Za\nOX2vZat7g5AZu8pK8g7kRohhK3xZlltNOsZs15dWxZHgfor+eYJnkBtsfJ1L\nToquthiAy5iAjLTiTlTQPsUO5AXJzmq1mn3FAl2CYRlX6oQrPi+mannGH4TQ\nFa1vD3WEvNDdFO+QElScACs5E1kJcgMOzH1f1MeG1J1lx17Qdax1gZU3DvNq\nDv79AJMslEbQM8e8Cq6pLEv1ZN9q2YcyjAeqCwt0EuJHvIXbNbPKDiDEzmii\nS+45W80no1ONRqjgFa9YQY6kOoDSF/K8pgTMrZOmck0khegeAqRyVzzY5tIP\n1rrn2R5nLrsqi4+9Ekb0tECAh8Hm39kcrCGn39ifdWkpoZm8ivIg82Ux51Ju\n9QFEObgEoPNF8RgjITGmrLzt1a6b7dbsdC8rSV371na0vhy+zPODHYoWoKoP\n6JOUtYmJSXD1SdHHvsfOp4Q78mOmnOCO281V5MwJnEy5fL8zt0cizSwGlPa0\nSNlLPIDZz14rZUfEbb4JZv9ZBA88cuo/TieIrP0n51vV8781zfZ80jYxZ/Si\nCjrq\r\n=I2Mm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC+qYOvDpax3nS0UDuVcjTnVhRKksNFCGURWMJfM8yYyQIgeYKoLKkbWIBiIO4yFG47/DX1Ypv8/x1rbZMK+pON18k="}],"size":3512,"noattachment":false,"key":"/crypto-random-string/-/crypto-random-string-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-random-string_3.1.0_1578813834652_0.18457452885833714"},"_hasShrinkwrap":false,"readme":"# crypto-random-string\n\n> Generate a [cryptographically strong](https://en.wikipedia.org/wiki/Strong_cryptography) random string\n\nCan be useful for creating an identifier, slug, salt, PIN code, fixture, etc.\n\nWorks in Node.js and browsers.\n\n## Install\n\n```sh\nnpm install crypto-random-string\n```\n\n## Usage\n\n```js\nimport cryptoRandomString from 'crypto-random-string';\n\ncryptoRandomString({length: 10});\n//=> '2cf05d94db'\n\ncryptoRandomString({length: 10, type: 'base64'});\n//=> 'YMiMbaQl6I'\n\ncryptoRandomString({length: 10, type: 'url-safe'});\n//=> 'YN-tqc8pOw'\n\ncryptoRandomString({length: 10, type: 'numeric'});\n//=> '8314659141'\n\ncryptoRandomString({length: 6, type: 'distinguishable'});\n//=> 'CDEHKM'\n\ncryptoRandomString({length: 10, type: 'ascii-printable'});\n//=> '`#Rt8$IK>B'\n\ncryptoRandomString({length: 10, type: 'alphanumeric'});\n//=> 'DMuKL8YtE7'\n\ncryptoRandomString({length: 10, characters: 'abc'});\n//=> 'abaaccabac'\n```\n\n## API\n\n### cryptoRandomString(options)\n\nReturns a randomized string. [Hex](https://en.wikipedia.org/wiki/Hexadecimal) by default.\n\n### cryptoRandomStringAsync(options)\n\nReturns a promise which resolves to a randomized string. [Hex](https://en.wikipedia.org/wiki/Hexadecimal) by default.\n\nFor most use-cases, there's really no good reason to use this async version. From the Node.js docs:\n\n> The `crypto.randomBytes()` method will not complete until there is sufficient entropy available. This should normally never take longer than a few milliseconds. The only time when generating the random bytes may conceivably block for a longer period of time is right after boot, when the whole system is still low on entropy.\n\nIn general, anything async comes with some overhead on it's own.\n\n```js\nimport {cryptoRandomStringAsync} from 'crypto-random-string';\n\nawait cryptoRandomStringAsync({length: 10});\n//=> '2cf05d94db'\n```\n\n#### options\n\nType: `object`\n\n##### length\n\n*Required*\\\nType: `number`\n\nLength of the returned string.\n\n##### type\n\nType: `string`\\\nDefault: `'hex'`\\\nValues: `'hex' | 'base64' | 'url-safe' | 'numeric' | 'distinguishable' | 'ascii-printable' | 'alphanumeric'`\n\nUse only characters from a predefined set of allowed characters.\n\nCannot be set at the same time as the `characters` option.\n\nThe `distinguishable` set contains only uppercase characters that are not easily confused: `CDEHKMPRTUWXY012458`. It can be useful if you need to print out a short string that you'd like users to read and type back in with minimal errors. For example, reading a code off of a screen that needs to be typed into a phone to connect two devices.\n\nThe `ascii-printable` set contains all [printable ASCII characters](https://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters): ``!\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~`` Useful for generating passwords where all possible ASCII characters should be used.\n\nThe `alphanumeric` set contains uppercase letters, lowercase letters, and digits: `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`. Useful for generating [nonce](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/nonce) values.\n\n##### characters\n\nType: `string`\\\nMinimum length: `1`\\\nMaximum length: `65536`\n\nUse only characters from a custom set of allowed characters.\n\nCannot be set at the same time as the `type` option.\n\n## Related\n\n- [random-int](https://github.com/sindresorhus/random-int) - Generate a random integer\n- [random-float](https://github.com/sindresorhus/random-float) - Generate a random float\n- [random-item](https://github.com/sindresorhus/random-item) - Get a random item from an array\n- [random-boolean](https://github.com/arthurvr/random-boolean) - Get a random boolean\n- [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object\n- [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object\n- [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-crypto-random-string?utm_source=npm-crypto-random-string&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","publish_time":1578813834762,"_cnpm_publish_time":1578813834762,"dist-tags":{"latest":"6.0.0"}}