# uid-safe

> URL and cookie safe UIDs

Latest version **2.1.5** (published 2017-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install uid-safe
pnpm add uid-safe
yarn add uid-safe
bun add uid-safe
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.5 |
| Published | 2017-08-03 |
| First published | 2014-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/uid-safe) |
| Module format | CommonJS |
| Node | >= 0.8 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 142 |
| Maintainers | dougwilson, fishrock123, jongleberry |
| Keywords | random, generator, uid, safe |

## Links

- npm: https://www.npmjs.com/package/uid-safe
- Repository: https://github.com/crypto-utils/uid-safe
- Homepage: https://github.com/crypto-utils/uid-safe#readme
- Issues: https://github.com/crypto-utils/uid-safe/issues
- npm.io page: https://npm.io/package/uid-safe

## Dependencies (1)

- [random-bytes](https://npm.io/package/random-bytes.md) ~1.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.1.5 (latest) — 2017-08-03
- 2.1.4 — 2017-03-03
- 2.1.3 — 2016-10-31
- 2.1.2 — 2016-08-15
- 2.1.1 — 2016-05-05
- 2.1.0 — 2016-01-17
- 2.0.0 — 2015-05-08
- 1.1.0 — 2015-02-14
- 1.0.3 — 2015-02-01
- 1.0.2 — 2015-01-08
- 1.0.1 — 2014-06-18
- 1.0.0 — 2014-06-18

## README

# uid-safe

[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]

URL and cookie safe UIDs

Create cryptographically secure UIDs safe for both cookie and URL usage.
This is in contrast to modules such as [rand-token](https://www.npmjs.com/package/rand-token)
and [uid2](https://www.npmjs.com/package/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.

## Installation

```sh
$ npm install uid-safe
```

## API

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

### uid(byteLength, callback)

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.

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

### uid(byteLength)

Asynchronously create a UID with a specific byte length and return a
`Promise`.

**Note**: To use promises in Node.js _prior to 0.12_, promises must be
"polyfilled" using `global.Promise = require('bluebird')`.

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

### uid.sync(byteLength)

A synchronous version of above.

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

## License

[MIT](LICENSE)

[npm-image]: https://img.shields.io/npm/v/uid-safe.svg
[npm-url]: https://npmjs.org/package/uid-safe
[node-version-image]: https://img.shields.io/node/v/uid-safe.svg
[node-version-url]: https://nodejs.org/en/download/
[travis-image]: https://img.shields.io/travis/crypto-utils/uid-safe/master.svg
[travis-url]: https://travis-ci.org/crypto-utils/uid-safe
[coveralls-image]: https://img.shields.io/coveralls/crypto-utils/uid-safe/master.svg
[coveralls-url]: https://coveralls.io/r/crypto-utils/uid-safe?branch=master
[downloads-image]: https://img.shields.io/npm/dm/uid-safe.svg
[downloads-url]: https://npmjs.org/package/uid-safe

---
_Source: https://npm.io/package/uid-safe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
