py-self-md5
py-self-md5 wraps a Python script so the generated script prints
MD5: <DIGEST> before running the original program.
The generated script does not read its own source file at runtime. Instead, the inserted prefix stores a quine-style byte template and computes the digest from the reconstructed bytes in memory.
This project is inspired by
zhuzilin/pdf-with-its-own-md5,
where selectable MD5-collision carriers are used to display the final digest in
a PDF. This tool targets executable Python programs and does not require
HashClash or precomputed collision blocks.
Install
Requires Python 3.11 or newer.
python -m pip install py-self-md5
After installation, run the built-in check:
py-self-md5 --self-test
You can also run it from the project root without installing:
python -m py_self_md5 --self-test
Usage
Create input.self_md5.py:
py-self-md5 input.py
Run the generated script:
python input.self_md5.py
The first output line is MD5: <DIGEST>, where <DIGEST> is the uppercase MD5
digest of input.self_md5.py; then the original program continues.
Write to a specific path:
py-self-md5 input.py -o output.py
Rewrite the input file in place:
py-self-md5 input.py --in-place
Replace an existing py-self-md5 prefix in place:
py-self-md5 input.py --in-place --force
Overwrite an existing output file:
py-self-md5 input.py -o output.py --force
Generate and verify in one step:
py-self-md5 input.py --check
What the wrapper preserves
- The tool preserves shebang lines, encoding cookies, module docstrings, and
from __future__ import ...placement. - By default, the input file is not modified.
- Existing
py-self-md5prefixes are detected. Use--forceto replace one.
Limitations
- This is an executable self-hash wrapper, not a general MD5 collision generator.
- The generated prefix can be large because it embeds enough bytes to reconstruct the generated script in memory.
--checkexecutes the generated script, so only use it with programs you are willing to run.
Metadata
Release files for py-self-md5 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_self_md5-0.1.0.tar.gz | 8.4 kB | Without provenance | Details for py_self_md5-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_self_md5-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for py_self_md5-0.1.0-py3-none-any.whl |
Total release size: 16.4 kB
Release files / py_self_md5-0.1.0.tar.gz
| Download URL | py_self_md5-0.1.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8713e81a6f24c01404525d49386aae1ddc0dfea48834c751a1e38c45f3d2d46
|
|
BLAKE2b-256 checksum How to use checksums |
10e831d4124663bf56a9c957e3967bc59170474763bffb2aa2e7606c1c28f10d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Release files / py_self_md5-0.1.0-py3-none-any.whl
| Download URL | py_self_md5-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9bfce1853d380c730db3cde3f9cc342cfb4e70b39bdb7eddc7a6fcfadb5a3720
|
|
BLAKE2b-256 checksum How to use checksums |
3f00cc58847501196d09753b7fec1028204e6d1c5cb3d334a0999f2065227255
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Security for py-self-md5 0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.