Skip to main content

callhash

Pure-Python WSJT-X compound-callsign hash resolution.

WSJT-X's FT4/FT8/WSPR packet formats compress compound callsigns (e.g. K1ABC/QRP, VE3/K1ABC) into 22-bit (FT8/FT4) or 15-bit (WSPR Type 3) hashes. Receivers maintain a session table that maps the hash back to plaintext when the call has been observed in a <call> first-occurrence message. Both jt9 and wsprd use the same hash function — Bob Jenkins lookup3, seed 146.

When a per-slot decoder invocation starts with an empty session table (the typical case for psk-recorder, meteor-scatter, wspr-recorder, or any consumer that drives the decoder one cycle at a time), most hashed packets surface as the literal <...> placeholder — or, when the decoder is told to emit the number (jt9 -Y, the patched decode_ft8), as <NNNNNNN>. This library reconstructs the table on the consumer side from the same announcement markers WSJT-X uses, and substitutes the numeric hashes back to plaintext.

All three HamSCI recorders use this one library for build (observe), lookup (by_hashNN), and substitution (resolve_token / resolve_message / parse_message) — the same mechanism everywhere, so a compound call learned on one mode/band resolves hashes on another. Every mode hashes with the identical nhash; only the width differs (22-bit FT8/FT4/MSK144/FST4W, 15-bit WSPR-2), and the table keys each width separately.

Install

pip install callhash

Or from a sibling checkout (HamSCI deployment pattern):

pip install -e /opt/git/sigmond/callhash

Usage

from callhash import CallHashTable, hash22, hash15, nhash

# Persistent per-station cache.
table = CallHashTable.load_or_new("/var/lib/myclient/callhash.json")

# Feed any text containing <call> markers; the table extracts them.
table.observe("260507 1234 -12 +0.45 1250 ` <K1ABC/QRP> CQ FT8")

# Look a hash up if you happen to have one.
table.by_hash22(hash22("K1ABC/QRP"))   # → "K1ABC/QRP"
table.by_hash15(hash15("K1ABC/QRP"))   # → "K1ABC/QRP"

# Resolve a decoded message: substitutes <NNNNNNN>/<CALL>, drops <...>.
table.resolve_message("AC0G <2288505> R-12")   # → "AC0G K9AN R-12" (if learned)

# Or parse a whole message into call fields, resolving hashes via the table.
from callhash import parse_message
parse_message("AC0G <2288505> R-12", table=table)
# → {"message": "AC0G K9AN R-12", "rx_call": "AC0G", "tx_call": "K9AN",
#    "grid": "", "report": -12}

# Persist for the next invocation.
table.save()

Public API

Symbol Purpose
nhash(key, initval) Bob Jenkins lookup3 32-bit hash. initval=146 matches WSJT-X.
hash22(call) Convenience: nhash(call) & 0x3FFFFF (FT8/FT4 compound-call width).
hash15(call) Convenience: nhash(call) & 0x7FFF (WSPR Type 3 width).
hash12(call) Convenience: 12-bit mask (some ARRL contest variants).
hash10(call) Convenience: 10-bit mask (narrowest WSJT-X variant).
CallHashTable Persistent accumulator + lookup + substitution + collision guard.
parse_message(msg, table=None) Shared WSJT-X message-field parser (tx/rx/grid/report) + hash substitution.

CallHashTable resolves with resolve_token / resolve_message, seeds decoders with write_wsprd_hashtable / write_jt9_calls (both take an exclude= predicate), and guards collisions: a hash slot claimed by two distinct calls is ambiguous, so by_hashNN returns None rather than a guessed (wrong) call. This matters because a persistent table accumulates far more calls than WSJT-X's per-session table, so collisions — especially in the 15-bit space — are common.

Correctness

nhash is bit-exact against WSJT-X's canonical lib/wsprcode/nhash.c (the unmasked variant — note that lib/wsprd/nhash.c has a 15-bit mask baked into its return). 23 reference vectors verified, including 11/12/13-byte boundary cases that exercise distinct final-block branches in the C code.

The CallHashTable covers <call> announcement extraction, hash lookups, token/message substitution, the collision guard, atomic JSON persistence (write-tempfile + rename), corrupt-JSON / schema-mismatch recovery, and concurrent-observe / concurrent-lookup safety. 89 tests total; no live ClickHouse / WSJT-X server required to run them.

Why this lives in its own repo

The hash function and bracket-resolution logic are WSJT-X's, not sigmond's. They're useful for any FT8/FT4/WSPR consumer — the sigmond client suite is the primary user today, but a future hs-uploader library or any independent log analyser will benefit equally. Pure stdlib, no runtime deps, ~200 lines of code; small enough to live cleanly on its own.

License

MIT.

Metadata

Release files for callhash 1.1.0

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

Source distribution (sdist)

Source distribution for callhash 1.1.0
File Size Uploaded Provenance Actions
callhash-1.1.0.tar.gz 22.4 kB With provenance Details for callhash-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for callhash 1.1.0
File Interpreter ABI Platform Actions
callhash-1.1.0-py3-none-any.whl Python 3 none any Details for callhash-1.1.0-py3-none-any.whl

Total release size: 38.8 kB

Release files / callhash-1.1.0.tar.gz

Download URL callhash-1.1.0.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a4e9b5f8cda751a6a3afa1c8275380c5dea6b34e7fb215b06c5cec68011c8b3e
BLAKE2b-256 checksum
How to use checksums
cec9200c8beb8d8d7522599d04bcc73cc6d9b435afd185a6fec89b312c88cd18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / callhash-1.1.0-py3-none-any.whl

Download URL callhash-1.1.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a344b83b1ae96b11ec9f502e8698d0b302477f10764d9a0dfd54b65ccdefaa8
BLAKE2b-256 checksum
How to use checksums
58434eeeb5d3b29675a51643f6a621b66efb913d44ec65ff99f12f1e5503fa27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for callhash 1.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for callhash-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full 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