{"_id":"@cjser/crypto-random-string__v4_0_0","name":"@cjser/crypto-random-string__v4_0_0","dist-tags":{"latest":"4.0.0-cjser.2"},"versions":{"4.0.0-cjser.2":{"name":"@cjser/crypto-random-string__v4_0_0","version":"4.0.0-cjser.2","description":"Generate a cryptographically strong random string","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"require":"./dist-cjser/index.cjs","default":"./index.js"},"engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["random","string","text","id","identifier","slug","salt","pin","crypto","strong","secure","hex","secret","protect"],"dependencies":{"type-fest":"^1.0.1"},"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.38.2"},"main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"4.0.0","cjserVersion":2,"original":{"name":"crypto-random-string","version":"4.0.0","exports":"./index.js","repository":"sindresorhus/crypto-random-string","dependencies":{"type-fest":"^1.0.1"},"files":["index.js","index.d.ts"],"scripts":{"test":"xo && ava && tsd"}}},"_id":"@cjser/crypto-random-string__v4_0_0@4.0.0-cjser.2","gitHead":"a4bef54d7d22d3d9a6b84528457938d84cd65fe7","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-uC/UNky2n36PBAfxP/yUFHoF9mY6+U7s+JecwatziJFmo+QkRAR+KgStd941I+zWFN3FEO8WVDAl54I2GsF9BQ==","shasum":"3034cfe7dd797138c53f5a75c66c45460ef6481c","tarball":"https://registry.npmjs.org/@cjser/crypto-random-string__v4_0_0/-/crypto-random-string__v4_0_0-4.0.0-cjser.2.tgz","fileCount":6,"unpackedSize":22672,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICs3UWZficK4hQfIiVBYSdQXouadeP3mk2Sey+RHRHbJAiEAoSzlsTeOId+dqAJwQp2kgfyEmpLPTYvuR8rmWhVw1NU="}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/crypto-random-string__v4_0_0_4.0.0-cjser.2_1778157744215_0.4413218540418604"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T12:42:24.122Z","4.0.0-cjser.2":"2026-05-07T12:42:24.351Z","modified":"2026-05-07T12:42:24.525Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Generate a cryptographically strong random string","keywords":["random","string","text","id","identifier","slug","salt","pin","crypto","strong","secure","hex","secret","protect"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","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\n## Install\n\n```\n$ npm 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### cryptoRandomString.async(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#### 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\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/crypto-random-string\n","readmeFilename":"readme.md","_rev":"1-2917daaf06cae8f394bf9af3afbfe670"}