{"name":"crypto-random-string","version":"5.0.0","description":"Generate a cryptographically strong random string","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-random-string.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","node":"./index.js","browser":"./browser.js"},"engines":{"node":">=14.16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["random","string","text","id","identifier","slug","salt","pin","crypto","strong","secure","hex","secret","protect"],"dependencies":{"type-fest":"^2.12.2"},"devDependencies":{"ava":"^4.2.0","dot-prop":"^7.2.0","tsd":"^0.20.0","xo":"^0.48.0"},"types":"./index.d.ts","gitHead":"25f8930282bc3803d03b9080e710db8426430b63","bugs":{"url":"https://github.com/sindresorhus/crypto-random-string/issues"},"homepage":"https://github.com/sindresorhus/crypto-random-string#readme","_id":"crypto-random-string@5.0.0","_nodeVersion":"16.15.0","_npmVersion":"8.3.2","dist":{"integrity":"sha512-KWjTXWwxFd6a94m5CdRGW/t82Tr8DoBc9dNnPCAbFI1EBweN6v1tv8y4Y1m7ndkp/nkIBRxUxAzpaBnR2k3bcQ==","shasum":"12b4ca8ba936c36d757b65b71a7d85a69a02c18a","tarball":"http://registry-npm.ywwl.com/crypto-random-string/download/crypto-random-string-5.0.0.tgz","fileCount":7,"unpackedSize":17683,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFCnMxHrBnzgA39mLUQpX6lVRD1qss9nwfDJvBz8oIwBAiEAnZWrxmScjNbfKqwEGNtp1klZKWmvjFyT23uo/eOH6LY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiegMIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpM9Q/9GQYHOC7tUwReyBAdE4gJuD82/oFeqxFY9+YkuV0C/R4dwP6m\r\nKPXjPgbygOKdbBoWvJUG46VT5HiHb9bQqOTMeefMrXn5amX7d6S/T2V3wN6d\r\nElYeFm3VRFC0g3wAxBj7u5/mGieg9IrDe1Zxn/JImUyDlF28ydJjJFsErucs\r\nh5+tWwqNQ5FtqyFuAD3thLFWFzXHsq1Q+QL3KoGIJs1rvhv9K51eyd0aqDaS\r\nWQR19M+56jM3RtYGTcjmMG+V2mD4lLQTZKdEMfyBaPNbQgV+jW3AYGOr3znp\r\nKwHZJ6NRB/wrkqHZnrXZrSMfWC2/hDZoQ5dDRUmpGMHD5cQ2bvfudiEUnlbY\r\nnXTQkPokWdbNaWcu7oiNtbldW8s/H7cp8yTh4/D5FLCfINjIFSUejXqvB/nL\r\nyiFj6N1OCf8DJxLXL9UKuiLCrdiAtoznS9nmF589RF35xc3hyjSf1a7KYphZ\r\n98iDVSzgKIupI7vzggZ6mIe8PJ0AmlfhVUhyGaVe74mBofAbe2dcf3C+rFeo\r\nM5ySshfa792Vecyiu+mWOCoTPt9IU+HFbl7pmQU9QQ/k8YcewSPHiS8cwVqD\r\nnvmDyiLEbRV4C2As40pWPgXn+kTAIRrNNe/l/jBelNbVZRfKRON3yM/imDX2\r\n/LGV9IGABr9ib8ZC4nOQc0OZbtvkKaNp4DY=\r\n=X0z/\r\n-----END PGP SIGNATURE-----\r\n","size":5294,"noattachment":false,"key":"/crypto-random-string/-/crypto-random-string-5.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-random-string_5.0.0_1652163335875_0.7548451044247599"},"_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":1652163336108,"_cnpm_publish_time":1652163336108,"dist-tags":{"latest":"6.0.0"}}