# idgen

> Minimal ID generator

Latest version **2.1.0** (published 2018-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install idgen
pnpm add idgen
yarn add idgen
bun add idgen
```

Provides the command `idgen`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2018-06-08 |
| First published | 2012-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Carlos Rodriguez |
| Maintainers | carlos8f |
| Keywords | uuid, id |

## Links

- npm: https://www.npmjs.com/package/idgen
- Repository: https://github.com/carlos8f/node-idgen
- Issues: https://github.com/carlos8f/node-idgen/issues
- npm.io page: https://npm.io/package/idgen

## 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.0 (latest) — 2018-06-08
- 2.0.2 — 2014-04-06
- 2.0.1 — 2014-04-06
- 2.0.0 — 2014-04-06
- 1.3.0 — 2013-06-22
- 1.2.0 — 2012-11-15
- 1.1.2 — 2012-09-11
- 1.1.1 — 2012-08-09
- 1.1.0 — 2012-08-09
- 1.0.2 — 2012-07-07
- 1.0.1 — 2012-07-07
- 1.0.0 — 2012-07-07

## README

idgen
-----

Minimal ID generator

[![build status](https://secure.travis-ci.org/carlos8f/node-idgen.png)](http://travis-ci.org/carlos8f/node-idgen)

Features (vs. traditional UUIDs):

- Uses [base64url](http://tools.ietf.org/html/rfc4648#section-5) encoding
  for compactness and readability. I think hex-based UUIDs are too long and
  hard to identify at a glance. base64url works nicely in URLs and can
  be generated from a Buffer.
- Supports deterministic IDs by passing in a Buffer, created using SHA or HMAC for example.
- Supports generating any length ID (adjust length to increase uniqueness or compactness).
- Can produce cryptographically secure random strings.

Install
=======

```bash
$ npm install idgen
```

Usage
=====

```javascript
var idgen = require('idgen');

// simple 8-character opaque id
idgen(8);
// returns: 1WWQ1OEc

// more collision-proof 16-character id:
idgen(16);
// returns: C1574ad7cX6ztPsD

// from a Buffer:
idgen(Buffer('8da307895368fcca53995503407f950c3291eb1d34af51237f500ac7e5bdf009', 'hex'));
// returns: jaMHiVNo_MpTmVUDQH-VDDKR6x00r1Ejf1AKx-W98Ak

// to get the Buffer back,
Buffer('jaMHiVNo_MpTmVUDQH-VDDKR6x00r1Ejf1AKx-W98Ak', 'base64').toString('hex')
// returns: 8da307895368fcca53995503407f950c3291eb1d34af51237f500ac7e5bdf009

// from a Buffer, truncated to 16 characters:
idgen(16, Buffer('8da307895368fcca53995503407f950c3291eb1d34af51237f500ac7e5bdf009', 'hex'));
// returns: jaMHiVNo_MpTmVUD
```

CLI version
===========

```bash
$ npm install -g idgen
$ idgen
1WWQ1OEc
$ idgen 16
C1574ad7cX6ztPsD
$ echo -n "carlos" | idgen
Y2FybG9z
```

License
=======

MIT

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