3 [![NPM Version][npm-image]][npm-url]
4 [![NPM Downloads][downloads-image]][downloads-url]
5 [![Node.js Version][node-version-image]][node-version-url]
6 [![Build Status][travis-image]][travis-url]
7 [![Test Coverage][coveralls-image]][coveralls-url]
9 URL and cookie safe UIDs
11 Create cryptographically secure UIDs safe for both cookie and URL usage.
12 This is in contrast to modules such as [rand-token](https://www.npmjs.com/package/rand-token)
13 and [uid2](https://www.npmjs.com/package/uid2) whose UIDs are actually skewed
14 due to the use of `%` and unnecessarily truncate the UID.
15 Use this if you could still use UIDs with `-` and `_` in them.
20 $ npm install uid-safe
26 var uid = require('uid-safe')
29 ### uid(byteLength, callback)
31 Asynchronously create a UID with a specific byte length. Because `base64`
32 encoding is used underneath, this is not the string length. For example,
33 to create a UID of length 24, you want a byte length of 18.
36 uid(18, function (err, string) {
38 // do something with the string
44 Asynchronously create a UID with a specific byte length and return a
47 **Note**: To use promises in Node.js _prior to 0.12_, promises must be
48 "polyfilled" using `global.Promise = require('bluebird')`.
51 uid(18).then(function (string) {
52 // do something with the string
56 ### uid.sync(byteLength)
58 A synchronous version of above.
61 var string = uid.sync(18)
68 [npm-image]: https://img.shields.io/npm/v/uid-safe.svg
69 [npm-url]: https://npmjs.org/package/uid-safe
70 [node-version-image]: https://img.shields.io/node/v/uid-safe.svg
71 [node-version-url]: https://nodejs.org/en/download/
72 [travis-image]: https://img.shields.io/travis/crypto-utils/uid-safe/master.svg
73 [travis-url]: https://travis-ci.org/crypto-utils/uid-safe
74 [coveralls-image]: https://img.shields.io/coveralls/crypto-utils/uid-safe/master.svg
75 [coveralls-url]: https://coveralls.io/r/crypto-utils/uid-safe?branch=master
76 [downloads-image]: https://img.shields.io/npm/dm/uid-safe.svg
77 [downloads-url]: https://npmjs.org/package/uid-safe