You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.4KB

4 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # crypto-random-string [![Build Status](https://travis-ci.org/sindresorhus/crypto-random-string.svg?branch=master)](https://travis-ci.org/sindresorhus/crypto-random-string)
  2. > Generate a [cryptographically strong](https://en.m.wikipedia.org/wiki/Strong_cryptography) random string
  3. Can be useful for creating an identifier, slug, salt, fixture, etc.
  4. ## Install
  5. ```
  6. $ npm install crypto-random-string
  7. ```
  8. ## Usage
  9. ```js
  10. const cryptoRandomString = require('crypto-random-string');
  11. cryptoRandomString(10);
  12. //=> '2cf05d94db'
  13. ```
  14. ## API
  15. ### cryptoRandomString(length)
  16. Returns a [`hex`](https://en.wikipedia.org/wiki/Hexadecimal) string.
  17. #### length
  18. Type: `number`
  19. Length of the returned string.
  20. ## Related
  21. - [random-int](https://github.com/sindresorhus/random-int) - Generate a random integer
  22. - [random-float](https://github.com/sindresorhus/random-float) - Generate a random float
  23. - [random-item](https://github.com/sindresorhus/random-item) - Get a random item from an array
  24. - [random-boolean](https://github.com/arthurvr/random-boolean) - Get a random boolean
  25. - [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object
  26. - [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object
  27. - [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique
  28. ## License
  29. MIT © [Sindre Sorhus](https://sindresorhus.com)