Human-readable deterministic pseudo-hash, based on coolname
Project description
For any int/str/bytes, return deterministic human-readable string generated by coolname.
>>> from coolname_hash import pseudohash_slug
>>> pseudohash_slug(123)
'ambrosial-amorphous-jackal-of-expertise'
>>> pseudohash_slug('qwerty')
'logical-ingenious-albatross-of-spirit'
>>> pseudohash_slug(b'\x00\x01\xFF')
'small-polar-mole-of-wholeness'
Get sequences instead of strings:
>>> from coolname_hash import pseudohash
>>> pseudohash('foobar')
['loud', 'gabby', 'finch', 'of', 'variation']
Pseudohash functions are stateless, thread-safe and don’t use the random module.
This package is a drop-in replacement for coolname, you can also import and use all of the ordinary functions like generate and generate_slug. You can create custom RandomGenerator as per documentation, and use pseudohash and pseudohash_slug methods.
WARNING: Random sequence varies from version to version of coolname, so make sure you pin version exactly in your project’s requirements file. You MUST include something like coolname_hash==1.0.0 or coolname_hash>=1.0,<2.0 in your project’s dependencies. Don’t specify coolname in your requirements file at all - coolname_hash always pins specific version of it. coolname version (except patches) only changes in major releases of coolname_hash.
If you care about consistency of pseudohashes across multiple executions of your application, the best practice is to add an import-time assert like this, with the actual pseudohash for 0:
from coolname_hash import pseudohash_slug
assert pseudohash_slug(0) == 'elusive-fabulous-sloth-of-wizardry' # NEVER CHANGE THIS LINE: specific version of coolname_hash is required
Caveats for variable types:
Same integer represented as int/str/bytes (e.g. 123, '123' and b'123') will yield the same result.
Same text as bytes and str will yield the same result when encoded in UTF-8.
Float/Decimal and Boolean values are not allowed (makes no sense anyway).
None is not allowed, you should handle it explicitly in your code.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coolname_hash-1.0.0.tar.gz.
File metadata
- Download URL: coolname_hash-1.0.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c404efad8d472a9f6b80ac815ccc09f7dfe43b6e4b2b5a06d3456f0727e3031
|
|
| MD5 |
fee13ac157200660c368879ba90e47b1
|
|
| BLAKE2b-256 |
5a603787b57593d7f2eb1acf40bea966428bf52414ffddb2820ef2019781ee3a
|
File details
Details for the file coolname_hash-1.0.0-py3-none-any.whl.
File metadata
- Download URL: coolname_hash-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
debd8a21b955dcb3ec93872430399b6d3fc8454d99ba34a4b798be3bf42aba68
|
|
| MD5 |
2e4307b584ea669a1071bf3af9c32bef
|
|
| BLAKE2b-256 |
d783fcbd75513b767ed686c2761af811d1c9726a8569c2720c1f531a9b07fbe6
|