Hash digest bytes, hex and Base64 can describe the same result in different forms. A comparison fails when one system expects raw digest bytes while another sends printed hexadecimal text. Our executed Python lab shows the distinction with six harmless inputs and three algorithms.
All 18 input–algorithm cases round-trip from hexadecimal and standard padded Base64 to the same digest bytes. By contrast, Base64-encoding the hexadecimal text produces a different payload in every case. These are interoperability checks, not a security benchmark or a recommendation to use legacy algorithms.
Why hash digest bytes, hex and Base64 differ
The 12 November entry in Cloudflare’s Rules changelog adds MD5, SHA-1 and SHA-512 functions. They accept strings or byte arrays and return raw bytes. Their output lengths are 16, 20 and 64 bytes respectively. The dated entry is the release hook; the page’s older generic update header is not the announcement date.
However, this article does not deploy a Cloudflare rule or test a cloud account. We use the announcement to frame a local representation exercise. The practical question is what crosses an interface: bytes, hexadecimal characters or Base64 characters.
A printed value is a representation
Python’s hashlib documentation distinguishes digest(), which returns bytes, from hexdigest(), which returns a hexadecimal string. The latter has twice as many characters as the digest has bytes. That changes presentation, not the underlying hash algorithm.
For example, a 16-byte digest becomes 32 hexadecimal characters. If those characters use ASCII, their encoded text occupies 32 bytes. Feeding that text to a Base64 encoder therefore encodes a different input from the original 16-byte digest. Both outputs can be valid Base64, yet they mean different things.
Derive the lengths before debugging the value
For an n-byte digest, hexadecimal uses 2n characters. Standard padded Base64 uses 4 × ceiling(n/3) characters. This follows the three-byte to four-character grouping described in RFC 4648. Padding completes the final group when necessary.
| Algorithm | Raw bytes | Hex characters | Padded Base64 characters |
|---|---|---|---|
| MD5 | 16 | 32 | 24 |
| SHA-1 | 20 | 40 | 28 |
| SHA-512 | 64 | 128 | 88 |

The formula describes standard padded Base64. An interface can instead specify a URL-safe alphabet or omit padding under its own contract. Therefore, record the variant and padding rule before comparing strings. Do not remove characters until you know what the receiving system expects.
Six inputs retain their exact UTF-8 bytes
Our fixture file contains an ASCII catalogue label, a fictional name with an accented character, an empty string, a trailing-newline variation, a space variation and a naira-denominated text label. We encode each explicitly as UTF-8. The CSV retains JSON-escaped source text, hexadecimal input bytes and the input byte count.
This makes an invisible newline inspectable. For instance, campus-book and the same text followed by a newline are different byte sequences. A space replacing the hyphen also changes the input. Those examples test input contracts rather than an output-encoding disagreement.
Similarly, a displayed accented character or naira symbol does not imply one input byte per visible character. Retain the encoding and actual byte sequence. The lab uses harmless invented content, so it does not require learner, customer or payment records.
What the executed 18-case lab establishes
We ran MD5, SHA-1 and SHA-512 for each of the six inputs. Every case produced the expected digest and representation lengths. Decoding its hexadecimal string and its padded Base64 string returned the original digest bytes. Both round-trip checks passed in all 18 cases.
Next, the program deliberately Base64-encodes the ASCII hexadecimal text. Decoding that output returns the hexadecimal text bytes, not the digest bytes. All 18 wrong-route comparisons fail against the original digest, exactly as expected. This is a useful negative control for an integration test.

The script records the Python version, platform and OpenSSL version in the saved run output. It would record an unsupported algorithm instead of changing environment restrictions. In this run, all three algorithms executed; no security setting or cloud configuration changed.
Use a diagnostic tree instead of guessing
First, establish whether both systems received identical input bytes. Check the encoding, newline policy, spaces and serialisation. If the bytes differ, resolve that contract before investigating how the digest is printed. Avoid silently trimming or normalising content because it looks similar.
Unlock Your Unique Tech Path
Get expert tech consulting tailored just for you. Receive personalized advice and solutions within 1-3 business days.
Get Started
If the inputs agree, compare the algorithm and any relevant parameters. Then identify the output form on each side. Decode hexadecimal or Base64 to bytes and compare the resulting digest bytes. Matching bytes establish agreement for that tested value, even when the displayed strings differ.
For a Nigerian coding class or portfolio exercise, the blank comparison ledger can document each interface explicitly. Record the input evidence, output representation, Base64 variant and unresolved questions. A small reproducible ledger is more useful than a screenshot of two unexplained strings.
Keep interoperability separate from security decisions
Python documents known collision weaknesses in MD5 and SHA-1. Do not choose them for a new security-sensitive design on the strength of this exercise. We include them to explain the specific legacy interoperability functions in the news hook. Encoding their output does not repair those weaknesses.
Moreover, Base64 is not encryption, and this is not a password-storage guide. A plain hash of personal information does not automatically make that information anonymous. Our lab measures representation behaviour only; it does not evaluate attacks, privacy protection or application security.
Download the reproducible lab
- Six exact UTF-8 input fixtures (CSV)
- All 18 executed digest and encoding results (CSV)
- Raw, hex, Base64 and double-encoding lengths (CSV)
- Blank interface comparison ledger (CSV)
- Python source, inputs and reproduction instructions (ZIP)
For another contract boundary, see our local JSON testing study. Our Python data-validation exercise also keeps a value attached to the metadata needed to interpret it.
Methodology and limitations
We executed this standard-library lab locally on 15 November 2026 using six designed inputs and three algorithms. The source pack retains the precise inputs, all observed output strings, length calculations, assertions and instructions. The outputs support reproduction of these cases, not a claim of complete implementation coverage.
Finally, no performance timing, cloud execution or security-strength comparison forms part of the study. The length arithmetic is deterministic, while the round-trip results describe this recorded local run. Confirm the receiving interface’s current contract before applying the example to a real integration.
