Urara-Blog/node_modules/.pnpm-store/v3/files/27/8912d76b7afa1de76a39bebe46ac2eed31827ef8160dbb8ec81d98acb05c3053b4d7da823c562c901e7d1c65fe57850d4e9c61eb48075f56761665443dbec6
2022-08-14 01:14:53 +08:00

51 lines
1.4 KiB
Text

# crypto-random-string [![Build Status](https://travis-ci.org/sindresorhus/crypto-random-string.svg?branch=master)](https://travis-ci.org/sindresorhus/crypto-random-string)
> Generate a [cryptographically strong](https://en.m.wikipedia.org/wiki/Strong_cryptography) random string
Can be useful for creating an identifier, slug, salt, fixture, etc.
## Install
```
$ npm install crypto-random-string
```
## Usage
```js
const cryptoRandomString = require('crypto-random-string');
cryptoRandomString(10);
//=> '2cf05d94db'
```
## API
### cryptoRandomString(length)
Returns a [`hex`](https://en.wikipedia.org/wiki/Hexadecimal) string.
#### length
Type: `number`
Length of the returned string.
## Related
- [random-int](https://github.com/sindresorhus/random-int) - Generate a random integer
- [random-float](https://github.com/sindresorhus/random-float) - Generate a random float
- [random-item](https://github.com/sindresorhus/random-item) - Get a random item from an array
- [random-boolean](https://github.com/arthurvr/random-boolean) - Get a random boolean
- [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object
- [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object
- [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)