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 **To use promises, you must define a global `Promise` if necessary.**
50 uid(18).then(function (string) {
51 // do something with the string
55 ### uid.sync(byteLength)
57 A synchronous version of above.
60 var string = uid.sync(18)
67 [npm-image]: https://img.shields.io/npm/v/uid-safe.svg
68 [npm-url]: https://npmjs.org/package/uid-safe
69 [node-version-image]: https://img.shields.io/node/v/uid-safe.svg
70 [node-version-url]: http://nodejs.org/download/
71 [travis-image]: https://img.shields.io/travis/crypto-utils/uid-safe/master.svg
72 [travis-url]: https://travis-ci.org/crypto-utils/uid-safe
73 [coveralls-image]: https://img.shields.io/coveralls/crypto-utils/uid-safe/master.svg
74 [coveralls-url]: https://coveralls.io/r/crypto-utils/uid-safe?branch=master
75 [downloads-image]: https://img.shields.io/npm/dm/uid-safe.svg
76 [downloads-url]: https://npmjs.org/package/uid-safe