Calculate a reproducible SHA-256 digest of exact UTF-8 text
Python
Compare text artifacts without silently changing line endings or normalization.
Compare text artifacts without silently changing line endings or normalization. This stdin-based Python CLI processes one bounded JSON request and returns the documented JSON result. It does not execute jobs or contact external services. Inspect its limits before adapting it to an application.
Before you start
Python 3.12 standard library; no third-party packages. Verified with the recorded pinned runtime.
One UTF-8 JSON object on stdin, no command-line arguments. Maximum encoded request size is 20000 bytes.
Build and check
Save the source as sha256-utf8-text-python.py.
Save the example JSON below as request.json.
Run python3 sha256-utf8-text-python.py < request.json.
Compare the parsed JSON result with the expected output. Invalid input exits 2 with empty stdout and a generic stderr message.
Limits to understand
SHA-256 is not encryption, a password hash, or proof of authenticity.
The 20000-byte limit applies to the entire JSON input, not just the text's UTF-8 representation.
The program preserves characters it receives; it cannot undo normalization or newline conversion performed upstream. An existing U+FEFF character in the text is preserved, not removed.
Input exactly {"text":string}. Encode exact text as UTF-8 without BOM; never normalize Unicode, whitespace or newline characters.
Output {"sha256": lowercase hexadecimal SHA-256 digest, "utf8_bytes":integer}. Empty text is valid.
Document that a digest is not encryption, a password hash or proof of authenticity.
The complete encoded input is limited to 20000 bytes; one additional byte can be read to detect overflow.
This is a bounded local helper. Passing the recorded cases does not verify every input, every Python version or an external integration.
Code license: MIT. Keep the license notice with your copy.
Example version 1.0.0 · Documentation reviewed 2026-11-15.
20 recorded CLI cases passed in rootless Docker on the pinned Python 3.12 runtime, with 512 MiB RAM, 1 CPU, no network, and read-only source. Other runtimes and all possible inputs are not verified.