Readable Gibberish Digests
Project description
regidi
18-bit or 24-bit Readable Gibberish Digests to use when you want a short, memorable representation of a hash function digest, UUID, or similar.
>>> import regidi
>>> regidi.digest18(187065) # Accepts int or bytes
'regidi'
Installation
Regidi is available on https://pypi.org/ and can be installed using pip:
pip install regidi
Usage
BYOH: This library does not provide a hash function - bring your own if you want digests of arbitrary data.
The digest functions accepts either an int
or bytes
object as input. This matches the output of for instance both the functions in the built-in
hashlib,
and the MurmurHash extension mmh3.
digest18
18-bit digest consisting of three syllables.
import hashlib
import regidi
digest = regidi.digest18(hashlib.sha1(b"1234567890").digest())
assert digest == "kagrafo"
Constructs the digest using the lowest 18 bits in the input.
digest24
24.63-bit digest with the same three syllables as digest18
together with two digits at the end, 01-99 (~6.63 bits).
import mmh3
import regidi
digest = regidi.digest24(mmh3.hash("regidi"))
assert digest == "raleca02"
If the input is smaller than $2^{18}$, digest24
will generate the same digest as digest18
with the digits 01
:
import regidi
d18 = regidi.digest18(0)
d24 = regidi.digest24(0)
assert d24 == f"{d18}01"
CLI
Installing the package also installs a CLI script to generate digests. Run with the --help
flag for more information:
regidi --help
Sanitized output
All theoretical digest outputs based on the initial set of syllables are checked against a list of bad words. Digests that contain any of the bad words are then substituted so that no digests contain any of the bad words on the list, while still retaining the 18-bit output. See tools/README.md for more information.
Development
This project uses PDM.
Updating bad-words.txt
The file bad-words.txt is not included in the distributed package.
Instead, the regidi.substitution
package contains automatically generated resource files
that determine how syllable substitution should be performed to avoid bad words in digests.
If bad-words.txt
is updated, these resource files have to be updated as well by running:
tools/manage.py update-substitution-data
Note: Changing the list of bad words also (very likely) changes the digest for inputs that require substitution.
This means that currently the digest functions are not guaranteed to produce the same output between versions if the bad-words.txt
file has been updated.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file regidi-0.1.0.tar.gz
.
File metadata
- Download URL: regidi-0.1.0.tar.gz
- Upload date:
- Size: 67.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.0 CPython/3.12.3 Linux/5.15.146.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32a9f5805e7cbbe848a0b70bd55878aac42a0cb4f4058dae719f214476dd3d0f |
|
MD5 | 06fb07b22f09ff3e348f18ae168763c3 |
|
BLAKE2b-256 | e45625dea98e717c40a7b1a3d1f5547bbe4e40ec950277ae468f2142370c7ce2 |
File details
Details for the file regidi-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: regidi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 65.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.0 CPython/3.12.3 Linux/5.15.146.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ba6986a2457ed1319101079f6dd469521f1479d9325e40eeec777baa239ee63 |
|
MD5 | 6435cbe11e610236d31e174f7705be1d |
|
BLAKE2b-256 | fff4e5f78c123020477a2b4d740ed9437b8ca6ca23a15adae69bad0305286e79 |