|
Last change
on this file since cdcff72 was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | # crypto-random-string [](https://travis-ci.org/sindresorhus/crypto-random-string)
|
|---|
| 2 |
|
|---|
| 3 | > Generate a [cryptographically strong](https://en.m.wikipedia.org/wiki/Strong_cryptography) random string
|
|---|
| 4 |
|
|---|
| 5 | Can be useful for creating an identifier, slug, salt, fixture, etc.
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | ## Install
|
|---|
| 9 |
|
|---|
| 10 | ```
|
|---|
| 11 | $ npm install crypto-random-string
|
|---|
| 12 | ```
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | ## Usage
|
|---|
| 16 |
|
|---|
| 17 | ```js
|
|---|
| 18 | const cryptoRandomString = require('crypto-random-string');
|
|---|
| 19 |
|
|---|
| 20 | cryptoRandomString(10);
|
|---|
| 21 | //=> '2cf05d94db'
|
|---|
| 22 | ```
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | ## API
|
|---|
| 26 |
|
|---|
| 27 | ### cryptoRandomString(length)
|
|---|
| 28 |
|
|---|
| 29 | Returns a [`hex`](https://en.wikipedia.org/wiki/Hexadecimal) string.
|
|---|
| 30 |
|
|---|
| 31 | #### length
|
|---|
| 32 |
|
|---|
| 33 | Type: `number`
|
|---|
| 34 |
|
|---|
| 35 | Length of the returned string.
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | ## Related
|
|---|
| 39 |
|
|---|
| 40 | - [random-int](https://github.com/sindresorhus/random-int) - Generate a random integer
|
|---|
| 41 | - [random-float](https://github.com/sindresorhus/random-float) - Generate a random float
|
|---|
| 42 | - [random-item](https://github.com/sindresorhus/random-item) - Get a random item from an array
|
|---|
| 43 | - [random-boolean](https://github.com/arthurvr/random-boolean) - Get a random boolean
|
|---|
| 44 | - [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object
|
|---|
| 45 | - [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object
|
|---|
| 46 | - [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | ## License
|
|---|
| 50 |
|
|---|
| 51 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.