Bridging Base64 API Digests and Hex CLI Checksums
Cloud APIs and HTTP standards such as AWS S3 Content-MD5, HTTP Digest / Repr-Digest, and HTML Subresource Integrity (sha256-...) encode binary hash digests in Base64 for compactness. Meanwhile, command-line tools like sha256sum, md5sum, and openssl dgst print the exact same raw bytes in hexadecimal.
ByteHelpers decodes either standard Base64 or Base64URL directly to a Uint8Array in browser memory and emits exact hexadecimal bytes alongside the bit width (128-bit MD5, 160-bit SHA-1, 256-bit SHA-256, 512-bit SHA-512) so you can verify checksums without writing one-off OpenSSL pipes.
- Byte RatioEach decoded byte renders as 2 hex digits (00–ff), so 32 bytes (44 Base64 chars) become 64 hex characters.
- Common Use CasesComparing AWS S3 Content-MD5 / ChecksumSHA256 headers and Subresource Integrity (SRI) digests against sha256sum hex output.
- Formatting ModesSupports continuous lowercase/uppercase hex, space-separated byte dump, and 0x-prefixed C/JS byte arrays.
Why is a Base64 SHA-256 hash 44 characters while the hex SHA-256 is 64 characters?
A SHA-256 digest is always 32 raw bytes (256 bits). Hex encodes 4 bits per character (256 / 4 = 64 chars), whereas Base64 encodes 6 bits per character (ceil(32 / 3) * 4 = 44 chars including one = pad).
Does converting Base64 to Hex change the underlying binary bytes?
No. Both Base64 and Hex are lossless representations of the exact same byte sequence.