← Cryptography guide

K083 / Encoding and decoding

Base32

Base32 encoding · Survey date 2026-12-05

Base32 is a text encoding using 32 characters to represent 5 bits at a time.

CRYPTOGRAPHY LAB / K083

Cryptography Lab · Base32

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Standard operation

Base32 (RFC 4648)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
Base32 is a text encoding using 32 characters to represent 5 bits at a time. Source document ↗
Classification and reversibility
Reversible encoding/decoding. Source document ↗
Key or secret requirements
No secret key; not encryption. Source document ↗
Operating principle and structure
5-bit symbols process five octets (40 bits) per block. Source document ↗
Key size, block size and parameters
Generally requires trailing '=' padding. Source document ↗
Security strength and recommendation
No confidentiality or cryptographic strength. Source document ↗
Known attacks and vulnerabilities
Padding/length differences may leak information. Source document ↗
Standards and certification
RFC 4648 standard. Source document ↗
Typical uses
Commonly represents OTP secrets. Source document ↗
Implementations, libraries and tools
Apache Commons Codec and other libraries. Source document ↗
Decryption or decoding
Decode function restores original bytes/string. Source document ↗
Advantages
Crockford variant tolerates case and ambiguous-character substitutions to reduce input errors. Source document ↗
Limitations and cautions
About 60% larger than input, increasing storage/transmission cost. Source document ↗
Distinguishing encryption, encoding and hashing
Not encryption/hash; adds no entropy or confidentiality. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

RFC 4648 encodes binary 'fooba' as 'MZXW6YTB'; decode to original bytes. No key/secret.

Procedure

Group 5 bytes, map 40 bits into eight 5-bit symbols and pad '=' if needed. Decode by reverse alphabet mapping, validate padding/illegal characters and reconstruct bytes; not encryption/decryption.

Scenario

Human-enterable TOTP secret text or binary IDs in restricted alphabet; agree RFC 4648 variant and padding.

Pitfalls and alternatives

Do not use for confidentiality. Mind padding/alphabet and base32hex/Crockford differences and nonstandard characters; protect sensitive data with TLS or cryptography.

References