# random-unique-id

> Generate 128bit hex unique id using true random seed, micro-second timestamp and counter for entropy

Latest version **2.1.0** (published 2023-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install random-unique-id
pnpm add random-unique-id
yarn add random-unique-id
bun add random-unique-id
```

## 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 | 2023-12-15 |
| First published | 2016-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ersun Warncke |
| Maintainers | ersun.warncke |

## Links

- npm: https://www.npmjs.com/package/random-unique-id
- Repository: https://github.com/warncke/random-unique-id
- Homepage: https://github.com/warncke/random-unique-id#readme
- Issues: https://github.com/warncke/random-unique-id/issues
- npm.io page: https://npm.io/package/random-unique-id

## Dependencies (1)

- [micro-timestamp](https://npm.io/package/micro-timestamp.md) 2.1.0

## Recent versions

- 2.1.0 (latest) — 2023-12-15
- 2.0.0 — 2021-04-03
- 1.1.0 — 2018-11-11
- 1.0.23 — 2018-01-15
- 1.0.22 — 2017-12-20
- 1.0.21 — 2017-12-18
- 1.0.20 — 2017-12-01
- 1.0.19 — 2017-11-13
- 1.0.18 — 2017-10-12
- 1.0.17 — 2017-10-11
- 1.0.16 — 2017-10-06
- 1.0.15 — 2017-10-04
- 1.0.14 — 2017-09-19
- 1.0.13 — 2017-09-10
- 1.0.12 — 2017-09-04
- … 23 more at https://npm.io/package/random-unique-id/versions

## README

# random-unique-id

Random Unique ID generates a 128-bit hex random id using `crypto.randomBytes` as
an initial seed and then concatenating this with a micro-second timestamp and an
incrementing counter and performing an SHA-256 hash to generate each unique id.

Random Unique IDs are intended to start from a truly random base and subsequently
to be deterministic but pseudo random.

As of version 1.0.0 the id is lower case where previously it was upper case.

## Usage

    const randomUniqueId = require('random-unique-id')

    var uniqueId = randomUniqueId()

    uniqueId.id        // 62793faaa26a55036957b79e3ef6a51b
    uniqueId.timestamp // 2017-05-29 21:18:31.844178

Random Unique ID returns an object with both the generated id and the timestamp
that was used to generate it.

## Accessing internal data

    const randomUniqueId = require('random-unique-id')

    randomUniqueId.count     // 0
    randomUniqueId.id        // undefined
    randomUnqiueId.seed      // 2ff54616eb6a411059031f77c2091771254e03daf4d3a431f70d13ba912e86b3
    randomUniqueId.processId // 06c441675a07ae8790e09e520ac05e86bce6ded412020a82e54bb762b336935a
    

    randomUniqueId()

    randomUniqueId.count     // 1
    randomUniqueId.id        // 7027ce98ca0ed9915841ac4fd7a74d42
    randomUnqiueId.seed      // 2ff54616eb6a411059031f77c2091771254e03daf4d3a431f70d13ba912e86b3
    randomUniqueId.processId // 06c441675a07ae8790e09e520ac05e86bce6ded412020a82e54bb762b336935a

Internal state data is exposed as properites of the unique id function. The `id`
will always contain the last id generated or be undefined if no ids have been
generated.

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