Skip to main content
hasheroku
============

Traditional hashing seems boring and mundane?
Can't bear the heartlessness of their musty hex strings?
Put down the razor: we have something for you.

.. code:: python

hasheroku('Hashing goes bananas!') # -> 'throbbing-mountain'
hasheroku('Hashing goes bananas.') # -> 'summer-frost'
hasheroku('Hasheroku goes bananas!') # -> 'withered-star'
hasheroku('Everything goes bananas!') # -> 'icy-thunder'

:code:`hasheroku` hashes strings into nice hashes, using heroku naming conventions.
It's like a heroku random names `generator`_, but hashing function!

**DISCLAIMER**: There are only 64x64 = 4096 unique combinations of heroku names, so *there will be a whole lot of collisions*.
That's why never use bare heroku hashes (i.e. without hex suffixes — explained `below`_) in the situations, where you are going to generate a lot of hashes!

.. _generator : https://github.com/usmanbashir/haikunator
.. _below : https://github.com/universome/hasheroku#usage

Installation
============
You can install :code:`hasheroku` using :code:`pip`:

.. code:: bash

pip install hasheroku

Usage
============
If you are not going to hash a lot of strings and/or do not care about collisions, than you can use it in a standard way:

.. code:: python

hasheroku('I love hashes!') # -> 'old-fiesta'

You can use your own separator with :code:`separator` argument:

.. code:: python

hasheroku('I love hashes!', separator='~') # -> 'old~fiesta'
hasheroku('Maaan, who does not like hashes?!', ' ') # -> 'lingering shadow'

If you are really serious and responsible about your hashing and would like to avoid collisions, then you can append part of the hash from the :code:`sha256` digest to the produced heroku hash.
This can be done with an optional :code:`suffix_len` argument:

.. code:: python

hasheroku('I love hashes!', suffix_len=5) # -> 'old-fiesta-cd298'
hasheroku('I love hashes!', 10, '~') # -> 'old~fiesta~cd29895f2a'
hasheroku('Maaan, who does not like hashes?!', 30, ' ') # -> 'lingering shadow a7c1c6cd56a755c3e87d9b667ef9dd'

In this case, of course, you lose all the awesomeness of human-readable hashes and can just use traditional hashing functions.

Are all names equally likely to be generated?
============
Yes. First, we get sha256 hash of the string, than we project its first 4 hexadecimal characters into heroku adjectives and names.
As long as these 4 characters are uniformly distributed (and they do) and we project them properly (and we do) — our hashes are uniformly distributed too.
The problem, of course, is with the tiny amount of possible names, that's why we have a lot of collisions.

Man, why?
============
This project can be useful when you regurarly deploy services/run experiments and want their names to be a hash of their config file.
Using traditional hashing like md5/sha256 makes the names look ugly and their large entropy is not needed at all in such a case.

Contributing and TODOs
============

.. |ss| raw:: html

<strike>

.. |se| raw:: html

</strike>

If you feel like you have nothing else to do with your life, you can contribute to this project.
It will be cool to make the following things:

* Write a proper test for uniformity. There is a Kolmogorov-Smirnov test to check if a random variable is uniform, but it works only with continuous variables. And I do not know how to check the same thing for discrete ones (friendly, I didn't google this much, because I was a little bit |ss| lazy |se| busy).
* Add more names and adjectives. This will allow us to reduce amount of collisions. Currently, I've hardcoded usage of only 64 adjectives/names. To sample properly I suppose we should take binary digest of the sha256 and use `this`_.

.. _this : https://stats.stackexchange.com/questions/70073/generating-discrete-uniform-from-coin-flips

Metadata

Release files for hasheroku 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hasheroku 0.1.2
File Size Uploaded Provenance
hasheroku-0.1.2.tar.gz 5.1 kB Without provenance Details

Release files / hasheroku-0.1.2.tar.gz

Download URL hasheroku-0.1.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e0ef75b81a9873f2b47416406c6b0efe83ba7d23574513fa6a6d32bd74cca4a9
BLAKE2b-256 checksum
How to use checksums
8cb6179db347bacfe92e0e0990ff4b66628b9c765c7e07005558843b1dfa23d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for hasheroku 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page