Sha256: faf15221d53af587bf9c1f5f2ec1061a924e99587436ffd964972337712114c4

Contents?: true

Size: 1.15 KB

Versions: 17

Compression:

Stored size: 1.15 KB

Contents

# UID Safe

Create cryptographically secure UIDs safe for both cookie and URL usage.
This is in contrast to modules such as [rand-token](https://github.com/sehrope/node-rand-token)
and [uid2](https://github.com/coreh/uid2) whose UIDs are actually skewed
due to the use of `%` and unnecessarily truncate the UID.
Use this if you could still use UIDs with `-` and `_` in them.

## API

```js
var uid = require('uid-safe')
```

### uid(byteLength, [cb])

Asynchronously create a UID with a specific byte length.
Because `base64` encoding is used underneath, this is not the string length!
For example, to create a UID of length 24, you want a byte length of 18!

If `cb` is not defined, a promise is returned.
However, to use promises, you must either install [bluebird](https://github.com/petkaantonov/bluebird)
or use a version of node.js that has native promises,
otherwise your process will crash and die.

```js
uid(18).then(function (string) {
  // do something with the string
})

uid(18, function (err, string) {
  if (err) throw err
  // do something with the string
})
```

### uid.sync(byteLength)

A synchronous version of above.

```js
var string = uid.sync(18)
```

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.4.1 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.4.0 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.3.0 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.2.1 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.2.0 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.1.0 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.0.8 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.0.7 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
hooch-0.0.6 jasmine/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/express-session/node_modules/uid-safe/README.md