I decided to withdraw this proposal with reasons explained in Expose `hashlib` and `hmac` as command-line utilities [withdrawn proposal] - #6 by picnixz.
The modules with a CLI are listed on Modules command-line interface (CLI) — Python 3.14.2 documentation. Among them we have base64 and encodings.rot_13 (which I wasn’t aware of until today). base64 is also available as a Unix command so we’re happy, and rot_13 is likely unused by most people. Now, offering base64 as a CLI tool is actually good on non-Unix systems such as Windows as they usually lack such built-in features.
We recently added a CLI for random and I would like to the same for hashlib and hmac. The tool would expose the following features:
- Indicate which algorithms are available for the given interpreter (which is something that users may not know about it), and possibly which implementation is being used (HACL* or OpenSSL) though this may require a bit more work as I don’t think hashlib objects retain their original implementation (except via their base class).
- Compute the digest/MAC of a given string, file, or stream (thus, avoiding the needs of
echo text | <command>or<command> <<< stringin general as well as making it supported on all platforms). - Compare digests/MAC of two strings, files or streams.
One could say that the openssl command-line already provides this, but OpenSSL commands are annoying to remember from one invokation to another (and the output may need sanitization as it contains other characters than the pure digest). On the other hand, OpenSSL’s BLAKE2s/2b implementation provides less configuration than what Python’s able to offer.
Likewise, it’s possible to compare checksums via sha256 -c file1 file2 or filecmp in Python (which does not compute checksums by the way).
My main motivation is therefore to expose a unified entrypoint for common cryptographic operations.
As a maintainer of hashlib, I could have pushed for this functionality without opening a thread here, but I wanted to hear from the community first as the intended audience is different.