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. # uid-safe
  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. URL and cookie safe UIDs
  8. Create cryptographically secure UIDs safe for both cookie and URL usage.
  9. This is in contrast to modules such as [rand-token](https://www.npmjs.com/package/rand-token)
  10. and [uid2](https://www.npmjs.com/package/uid2) whose UIDs are actually skewed
  11. due to the use of `%` and unnecessarily truncate the UID.
  12. Use this if you could still use UIDs with `-` and `_` in them.
  13. ## Installation
  14. ```sh
  15. $ npm install uid-safe
  16. ```
  17. ## API
  18. ```js
  19. var uid = require('uid-safe')
  20. ```
  21. ### uid(byteLength, callback)
  22. Asynchronously create a UID with a specific byte length. Because `base64`
  23. encoding is used underneath, this is not the string length. For example,
  24. to create a UID of length 24, you want a byte length of 18.
  25. ```js
  26. uid(18, function (err, string) {
  27. if (err) throw err
  28. // do something with the string
  29. })
  30. ```
  31. ### uid(byteLength)
  32. Asynchronously create a UID with a specific byte length and return a
  33. `Promise`.
  34. **Note**: To use promises in Node.js _prior to 0.12_, promises must be
  35. "polyfilled" using `global.Promise = require('bluebird')`.
  36. ```js
  37. uid(18).then(function (string) {
  38. // do something with the string
  39. })
  40. ```
  41. ### uid.sync(byteLength)
  42. A synchronous version of above.
  43. ```js
  44. var string = uid.sync(18)
  45. ```
  46. ## License
  47. [MIT](LICENSE)
  48. [npm-image]: https://img.shields.io/npm/v/uid-safe.svg
  49. [npm-url]: https://npmjs.org/package/uid-safe
  50. [node-version-image]: https://img.shields.io/node/v/uid-safe.svg
  51. [node-version-url]: https://nodejs.org/en/download/
  52. [travis-image]: https://img.shields.io/travis/crypto-utils/uid-safe/master.svg
  53. [travis-url]: https://travis-ci.org/crypto-utils/uid-safe
  54. [coveralls-image]: https://img.shields.io/coveralls/crypto-utils/uid-safe/master.svg
  55. [coveralls-url]: https://coveralls.io/r/crypto-utils/uid-safe?branch=master
  56. [downloads-image]: https://img.shields.io/npm/dm/uid-safe.svg
  57. [downloads-url]: https://npmjs.org/package/uid-safe