# cyclical-object-hash

> Deterministically hash a cyclical object with blake2b

Latest version **0.2.0** (published 2019-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install cyclical-object-hash
pnpm add cyclical-object-hash
yarn add cyclical-object-hash
bun add cyclical-object-hash
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2019-06-16 |
| First published | 2019-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | jdvorak |
| Keywords | hash, blake, blake2b, object-hashing, deterministic, cylical object hash |

## Links

- npm: https://www.npmjs.com/package/cyclical-object-hash
- Repository: https://github.com/jdvorak/cyclical-object-hash
- Homepage: https://github.com/jdvorak/cyclical-object-hash#readme
- Issues: https://github.com/jdvorak/cyclical-object-hash/issues
- npm.io page: https://npm.io/package/cyclical-object-hash

## Dependencies (2)

- [blake2b](https://npm.io/package/blake2b.md) 2.1.3
- [safe-stable-stringify](https://npm.io/package/safe-stable-stringify.md) ^1.1.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2019-06-16
- 0.1.0 — 2019-06-16
- 0.0.5 — 2019-06-16
- 0.0.4 — 2019-06-16
- 0.0.3 — 2019-06-16
- 0.0.2 — 2019-06-16
- 0.0.1 — 2019-06-16
- 0.0.0 — 2019-06-16

## README

# cylical-object-hash [![stability][0]][1]
[![npm version][2]][3] 
[![downloads][8]][9] [![js-standard-style][10]][11]

Hash a cyclical object deterministically using blake2b.

## Why?
There are so many of these, so why yet another object hashing library? I found all the other options lacking in one or another way. They all failed in at least one of the following ways:
1. Did not have a deterministic stringification step.
2. Broke on cyclical references.
3. Used an insecure hashing algorithm such as md5 or sha1 instead of blake2b. 
4. Limited to Node.js
5. Too hard to find on NPM.

## Usage
```js
const objectHash = require('cylical-object-hash')

let exampleObject = {
  "@context": "http://schema.org",
  "@type": "Book",
  "copyrightHolder": {
    "@type": "Organization",
    "name": "Holt, Rinehart and Winston"
  },
  "copyrightYear": "2007",
  "description": "NIMAC-sourced textbook",
  "genre": "Educational Materials",
  "inLanguage": "en-US",
  "isFamilyFriendly": "true",
  "isbn": "9780030426599",
  "name": "Holt Physical Science",
  "numberOfPages": "598",
  "publisher": {
    "@type": "Organization",
    "name": "Holt, Rinehart and Winston"
  }
}

objectHash.hex(exampleObject)
// '79fc74f0dd70d955a7d61271d09f0806aadff55ea770621cbb9a9194e9b9053cc59c3ca669b273dd0fb1a0efc4617d2c9824a339ad0200fdbd231b549f946027'

objectHash(exampleObject)
// Uint8Array 
// Blake2b { digestLength: 64, finalized: false, pointer: 64 }
```

## API
### objectHash(obj, [key], [salt], [personal])
This takes an ordinary object and will deterministically hash it via blake2b. It returns a Uint8Array by default. All optionals arguments such as key, salt, and personal will be passed to [blake2b](https://github.com/emilbayes/blake2b).

### .hex(obj, [key], [salt], [personal])
This takes an ordinary object and will deterministically hash it via blake2b. Unlike the function above, it returns it as a hex string. All optionals arguments such as key, salt, and personal will be passed to [blake2b](https://github.com/emilbayes/blake2b).

## Installation
```sh
$ npm install cyclical-object-hash
```

## License
[MIT](https://tldrlegal.com/license/mit-license)

[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square
[1]: https://nodejs.org/api/documentation.html#documentation_stability_index
[2]: https://img.shields.io/npm/v/cyclical-object-hash.svg?style=flat-square
[3]: https://npmjs.org/package/cyclical-object-hash
[4]: https://img.shields.io/travis/jdvorak/cyclical-object-hash/master.svg?style=flat-square
[6]: https://img.shields.io/codecov/c/github/jdvorak/object-hash/master.svg?style=flat-square
[7]: https://codecov.io/github/jdvorak/cyclical-object-hash
[8]: http://img.shields.io/npm/dm/cyclical-object-hash.svg?style=flat-square
[9]: https://npmjs.org/package/cyclical-object-hash
[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[11]: https://github.com/feross/standard

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