An open API service indexing awesome lists of open source software.

https://github.com/arcticicestudio/icecore-hashids

A lightweight generator for short, unique, non-sequential and decodable Hashids from non-negative numbers.
https://github.com/arcticicestudio/icecore-hashids

hash hash-algorithm hash-numbers hashids icecore java library obfuscation obfuscator

Last synced: 19 days ago
JSON representation

A lightweight generator for short, unique, non-sequential and decodable Hashids from non-negative numbers.

Awesome Lists containing this project

README

        

---

A lightweight generator for short, unique, non-sequential and decodable Hashids from non-negative numbers.

Implementation of the Hashids algorithm.

[Hashids][hashids] are obfuscated unique hashes of non-negative (long) integer numbers, but in contrast to cryptographic one-way hash algorithms they are can be decoded again. The algorithm can be used to either generate a hash from a single number or bundling several numbers into one to be stored as simple short UIDs. This design allows to use them for many use-cases like

* URL shortening
* database ID protection
* shard numbers storage
* invitation-, authorization- and gift codes
* complex- or clustered system parameters

Numbers like `347` are converted into strings like `yr8`, or an array of numbers like `[27, 986]` into `3kTMd`.

## Features

The **algorithm** provides the following features:

* Generation of short, unique, case-sensitive and non-sequential [decodable][docs-api-guide-decoding] hashes of natural numbers
* Additional entropy through [salt][docs-api-guide-config-salt] usage
* Configurable [minimum hash length][docs-api-guide-config-min-hash-length] and [alphabet][docs-api-guide-config-alphabet]
* Combining of [several numbers to one hash][docs-api-guide-encoding]
* Deterministic hash computation given the same input and parametrization/[instance configuration][docs-api-instances]
* [Prevention of curse words][docs-api-curse-word-prevention] through separator characters

In addition, the **library** provides features to

* pass `0x` or `0X` [prefixed hexadecimal numbers][docs-api-guide-config-feature-hex-prefix] to the public API methods
* [handle exceptions][docs-api-guide-config-feature-exception-handling] instead of returning empty values when invalid parameters are passed to any public API method
* [disable the maximum number size limit][docs-api-guide-config-feature-no-max-number-size] which ensures the interoperability with the [algorithm reference implementation][hashids-js] and allows the usage of the Java `Long` [maximum value][long-max-value]

> Please note that most features will break the interoperability with the [algorithm reference implementation][hashids-js]!

## Getting Started

The [project documentation][docs] contains chapters to learn about the [installation][docs-getting-started-installation] and [requirements][docs-getting-started-requirements], get an [overview][docs-api] of the API and [learn how to use it][docs-api-guide], and [build][docs-dev-building] the project and [running the tests][docs-dev-testing].

## Contributing

Read the [contributing guide][docs-dev-contributing] to learn about the development process and how to propose [enhancement suggestions][docs-dev-contributing-enhancements] and [report bugs][docs-dev-contributing-bug-reports], how to [submit pull requests][docs-dev-contributing-pr] and the project's [styleguides][docs-dev-contributing-styleguides], [branch organization][docs-dev-contributing-branch-org] and [versioning][docs-dev-contributing-versioning] model.

The guide also includes information about [minimal, complete, and verifiable examples][docs-dev-contributing-mcve] and other ways to contribute to the project like [improving existing issues][docs-dev-contributing-other-improve-issues] and [giving feedback on issues and pull requests][docs-dev-contributing-other-feedback].

---

Copyright © 2016-present Arctic Ice Studio

[docs]: https://arcticicestudio.github.io/icecore-hashids
[docs-api]: https://arcticicestudio.github.io/icecore-hashids/api
[docs-api-curse-word-prevention]: https://arcticicestudio.github.io/icecore-hashids/api/curse-word-prevention.html
[docs-api-guide]: https://arcticicestudio.github.io/icecore-hashids/api/guide
[docs-api-guide-config-alphabet]: https://arcticicestudio.github.io/icecore-hashids/api/guide/configuration/#determine-a-custom-alphabet
[docs-api-guide-config-feature-exception-handling]: https://arcticicestudio.github.io/icecore-hashids/api/guide/configuration/features.html#exception-handling
[docs-api-guide-config-feature-hex-prefix]: https://arcticicestudio.github.io/icecore-hashids/api/guide/configuration/features.html#allow-hexadecimal-number-prefixes
[docs-api-guide-config-feature-no-max-number-size]: https://arcticicestudio.github.io/icecore-hashids/api/guide/configuration/features.html#no-number-size-limit
[docs-api-guide-config-min-hash-length]: https://arcticicestudio.github.io/icecore-hashids/api/guide/configuration/#defining-a-minimum-hash-length
[docs-api-guide-config-salt]: https://arcticicestudio.github.io/icecore-hashids/api/guide/configuration/#using-a-salt
[docs-api-guide-decoding]: https://arcticicestudio.github.io/icecore-hashids/api/guide/decoding.html
[docs-api-guide-encoding]: https://arcticicestudio.github.io/icecore-hashids/api/guide/encoding.html
[docs-api-instances]: https://arcticicestudio.github.io/icecore-hashids/api/instances.html
[docs-dev-building]: https://arcticicestudio.github.io/icecore-hashids/development/building.html
[docs-dev-contributing]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html
[docs-dev-contributing-branch-org]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#branch-organization
[docs-dev-contributing-bug-reports]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#bug-reports
[docs-dev-contributing-enhancements]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#enhancement-suggestions
[docs-dev-contributing-mcve]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#mcve
[docs-dev-contributing-other-feedback]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#give-feedback-on-issues-and-pull-requests
[docs-dev-contributing-other-improve-issues]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#improve-issues
[docs-dev-contributing-pr]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#pull-requests
[docs-dev-contributing-styleguides]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#styleguides
[docs-dev-contributing-versioning]: https://arcticicestudio.github.io/icecore-hashids/development/contributing.html#versioning
[docs-dev-testing]: https://arcticicestudio.github.io/icecore-hashids/development/testing.html
[docs-getting-started-installation]: https://arcticicestudio.github.io/icecore-hashids/getting-started/installation.html
[docs-getting-started-requirements]: https://arcticicestudio.github.io/icecore-hashids/getting-started/requirements.html
[hashids]: http://hashids.org
[hashids-js]: https://github.com/ivanakimov/hashids.js
[long-max-value]: https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#MAX_VALUE