Ohm-Management - Projektarbeit B-ME
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 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # random-bytes
  2. [![NPM Version][npm-image]][npm-url]
  3. [![NPM Downloads][downloads-image]][downloads-url]
  4. [![Node.js Version][node-version-image]][node-version-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Test Coverage][coveralls-image]][coveralls-url]
  7. Generate strong pseudo-random bytes.
  8. This module is a simple wrapper around the Node.js core `crypto.randomBytes` API,
  9. with the following additions:
  10. * A `Promise` interface for environments with promises.
  11. * For Node.js versions that do not wait for the PRNG to be seeded, this module
  12. will wait a bit.
  13. ## Installation
  14. ```sh
  15. $ npm install random-bytes
  16. ```
  17. ## API
  18. ```js
  19. var randomBytes = require('random-bytes')
  20. ```
  21. ### randomBytes(size, callback)
  22. Generates strong pseudo-random bytes. The `size` argument is a number indicating
  23. the number of bytes to generate.
  24. ```js
  25. randomBytes(12, function (error, bytes) {
  26. if (error) throw error
  27. // do something with the bytes
  28. })
  29. ```
  30. ### randomBytes(size)
  31. Generates strong pseudo-random bytes and return a `Promise`. The `size` argument is
  32. a number indicating the number of bytes to generate.
  33. **Note**: To use promises in Node.js _prior to 0.12_, promises must be
  34. "polyfilled" using `global.Promise = require('bluebird')`.
  35. ```js
  36. randomBytes(18).then(function (string) {
  37. // do something with the string
  38. })
  39. ```
  40. ### randomBytes.sync(size)
  41. A synchronous version of above.
  42. ```js
  43. var bytes = randomBytes.sync(18)
  44. ```
  45. ## License
  46. [MIT](LICENSE)
  47. [npm-image]: https://img.shields.io/npm/v/random-bytes.svg
  48. [npm-url]: https://npmjs.org/package/random-bytes
  49. [node-version-image]: https://img.shields.io/node/v/random-bytes.svg
  50. [node-version-url]: http://nodejs.org/download/
  51. [travis-image]: https://img.shields.io/travis/crypto-utils/random-bytes/master.svg
  52. [travis-url]: https://travis-ci.org/crypto-utils/random-bytes
  53. [coveralls-image]: https://img.shields.io/coveralls/crypto-utils/random-bytes/master.svg
  54. [coveralls-url]: https://coveralls.io/r/crypto-utils/random-bytes?branch=master
  55. [downloads-image]: https://img.shields.io/npm/dm/random-bytes.svg
  56. [downloads-url]: https://npmjs.org/package/random-bytes