Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danakt/uuid-by-string
Generates the RFC-4122 Name-Based UUID
https://github.com/danakt/uuid-by-string
guid hash md5 rfc-4122 sha-1 uuid uuid-by-string v3 v5
Last synced: 15 days ago
JSON representation
Generates the RFC-4122 Name-Based UUID
- Host: GitHub
- URL: https://github.com/danakt/uuid-by-string
- Owner: danakt
- License: mit
- Created: 2016-10-08T22:13:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-09T16:28:12.000Z (2 months ago)
- Last Synced: 2024-10-23T14:07:31.679Z (21 days ago)
- Topics: guid, hash, md5, rfc-4122, sha-1, uuid, uuid-by-string, v3, v5
- Language: JavaScript
- Homepage:
- Size: 692 KB
- Stars: 66
- Watchers: 2
- Forks: 12
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
uuid-by-string
[![NPM](https://img.shields.io/npm/v/uuid-by-string.svg?style=flat-square&maxAge=3600)](https://www.npmjs.com/package/uuid-by-string)
[![Downloads](https://img.shields.io/npm/dw/uuid-by-string.svg?style=flat-square&maxAge=3600)](https://www.npmjs.com/package/uuid-by-string)
=======================
Generates the [RFC-4122](https://tools.ietf.org/html/rfc4122#section-4.3) Name-Based UUID. Supports 3 and 5 versions of UUID.## Installation
```bash
# via NPM
npm install uuid-by-string# or Yarn
yarn add uuid-by-string
```## Usage
The package has only one default exported method. Method receives any string and returns generated hash
```js
const getUuid = require('uuid-by-string');const uuidHash = getUuid('Hello world!');
// d3486ae9-136e-5856-bc42-212385ea7970
```The string `Hello world!` will always returns `d3486ae9-136e-5856-bc42-212385ea7970`.
You can specify the UUID version. Available versions is 3 and 5 according to [RFC-4122](https://tools.ietf.org/html/rfc4122#section-4.3). The version is responsible for the hashing algorithm: version 3 uses MD5, and version 5 uses SHA-1. SHA-1 used by default if version is not specified.
```js
const uuidV3Hash = getUuid('Hello world!', 3);
// 86fb269d-190d-3c85-b6e0-468ceca42a20const uuidV5Hash = getUuid('Hello world!', 5);
// d3486ae9-136e-5856-bc42-212385ea7970
```## API
`getUuid(name [, version]);`
`getUuid(name [, namespace, version]);`
- `name` — hashing target
- `namespace` _Optional_ — UUID namespace
- `version` _Optional_ — 3 or 5, version of UUID## License
[MIT licensed](LICENSE)