{"name":"crypto-random-string","version":"3.3.1","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":"d78436d6d0b36029d0f54d3b6cabadc3f3872755","bugs":{"url":"https://github.com/sindresorhus/crypto-random-string/issues"},"homepage":"https://github.com/sindresorhus/crypto-random-string#readme","_id":"crypto-random-string@3.3.1","_nodeVersion":"10.22.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-5j88ECEn6h17UePrLi6pn1JcLtAiANa3KExyr9y9Z5vo2mv56Gh3I4Aja/B9P9uyMwyxNHAHWv+nE72f30T5Dg==","shasum":"13cee94cac8001e4842501608ef779e0ed08f82d","tarball":"http://registry-npm.ywwl.com/crypto-random-string/download/crypto-random-string-3.3.1.tgz","fileCount":5,"unpackedSize":14308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJlWPCRA9TVsSAnZWagAAN34P/jXZ2e4ypARY6EwzUQtg\n8jH+kmhZBu1yyz2SSPLzfoqLxxjB13xpFI9myUVsCkkA3LZ2pAq7uB0FjvXl\njEUue5t8mQ+EeOmGdFMdG759rkdsegFsY8IuXTTupThUOMxeXjvijPJ1lRoV\nnonNU+BSdsES2uCHkN1xR9ko7ahwcYyWtje5IWO8K9PrE9K5J6RMBOtUNnHG\nIx9cR0wknkyqSeGLH1Z/ZZ5ED7DpophXa3jt4yscApdZDNaJWAxWy4VfQv6x\n6YbHw2SwKAgXiXudGr9G2I1j//2rDwNYLZUdcvTiIwNvoV7Rca0kkMSMYXtO\nB4EU+Vae7aoO0v3dqGYQnjbGur4z/taoBuGDTWGjFcAwo3DDyE5WxVDZKyZd\n3MKErYQeYs2qMlpVglIjshavwlZCDiqxyoR2bQHsmOB93AzkZUET+5ruCs8Q\nGhSctgnnhyWFdtLb/XtKvnsxVbmgzj2d5MSycXKKLMuJoeJEXegH2tsL1uQ5\nSTJQ5LfiwgwTLcQQ3pIDNSnBAJEzEQxHM71hVDMBuOiuDNHuYKlaLYFA4MbG\nSstEQjIgo9s5Lh0bQ+9eBWjk4PML9jGhksWaBBgR0DuhSBjhWW6IliunRtbT\nJIOt+euzNv67e2lV8CKlWi7B9snhvcLSlsYxWQsafVBcsB+nLdzckoHazr12\nti9s\r\n=KvSJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDUTDHKVlPCX60Lnrw+QiBVVu+ei21IwTot8ZDaF0f0ugIgCc5FrrRNw+hvF2Urbqec70w8qWghEq8yCwfKm0pAlOQ="}],"size":4328,"noattachment":false,"key":"/crypto-random-string/-/crypto-random-string-3.3.1.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-random-string_3.3.1_1613125007162_0.845884375786154"},"_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":1613125007305,"_cnpm_publish_time":1613125007305,"dist-tags":{"latest":"6.0.0"}}