Calculate WKD (Web-Key-Directory) UID Hashes for OpenGPG UIDs
Project description
wkdhash
Calculate Web-Key-Directory hashes of OpenPGP UIDs.
The Web-Key-Directory (WKD) is a method for deploying OpenPGP public keys for an email address through HTTPS.
For this, the keys user IDs are decomposed into their mailbox local part (the thing before the @ sign). This is then sha1 hashed and z-base-32 encoded, resulting in the "hu" (hashed user-id, I guess?).
The public key is then made available under a well-known URL containing the hu. So to deploy your public key to your webserver, you have to figure out what your uid's hu is. This can be done with
gpg --list-keys --with-wkd-hash $IDENTITY
but it is not easily doable from Python when using python-gnupg.
API
A single function is the only thing you really need:
from wkdhash import userid_to_wkd_hash
assert(userid_to_wkd_hash("mail@example.com") == "dizb37aqa5h4skgu7jf1xjr4q71w4paq")
assert(userid_to_wkd_hash("Test User <mail@example.com>", include_domain=True) == "dizb37aqa5h4skgu7jf1xjr4q71w4paq@example.com")
Command-line-utility
A simple command line utility entry-point is provided by this package, which reads user IDs from an input stream (default stdin) and writes the hu to an output stream (default stdout). So this module can also be used for bash scripting.
usage: wkdhash [-h] [-F] [-o outfile] [infile]
Read OpenPGP User IDs line-by-line and print their corresponding Web-Key-Directory hashed-user-id (hu).
positional arguments:
infile Input OpenPGP UserID, defaults to stdin
options:
-h, --help show this help message and exit
-F, --full If set, output 'hu@domain', instead of just 'hu'
-o, --output outfile Output, default stdout
MIT License, Copyright (c) 2025 Gregor Vollmer
Example Usage
$ echo "mail@example.com" | poetry run wkdhash
dizb37aqa5h4skgu7jf1xjr4q71w4paq
$ echo "Test User <mail@example.com>" | poetry run wkdhash -F
dizb37aqa5h4skgu7jf1xjr4q71w4paq@example.com
$ poetry run wkdhash
mail@example.com^Ddizb37aqa5h4skgu7jf1xjr4q71w4paq
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 wkdhash-0.1.0.tar.gz.
File metadata
- Download URL: wkdhash-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.2-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4560c2f02fbac9be421373fe9a1f67d11d0ac9d48f5f1b91f704a6cb1714aa59
|
|
| MD5 |
b156501b561a0b5d47455d4a2b446942
|
|
| BLAKE2b-256 |
632f886077028785719817d195a7d73d7559feb6c397accc85b5b0f4c57f431b
|
File details
Details for the file wkdhash-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wkdhash-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.2-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca9f3d4bdfff6b13a4effdde1ffcb2cc6ca888e0a8dc34b1e88fe3dc9719a035
|
|
| MD5 |
296c49e0f79ff298917436b9855382c0
|
|
| BLAKE2b-256 |
b1d1df10cd72f3beaa2b502c45c34cb2b00c293c51768443a1874f30bd1f9471
|