Go encoding/base32: RFC 4648 encodings, including the hex alphabet
Answer: Package base32 implements base32 encoding as specified by RFC 4648, including the standard and extended hex alphabets.
Alphabets and padding
An Encoding is a radix-32 scheme defined by a 32-character alphabet.
The most common alphabet is the base32 encoding introduced for SASL GSSAPI and standardized in RFC 4648.
StdEncoding uses the alphabet A-Z followed by 2-7.
HexEncoding uses the Extended Hex Alphabet from the same RFC, and it is typically used in DNS.
The alternate base32hex encoding is used in DNSSEC.
StdPadding is the standard padding character. NoPadding is no padding.
NewEncoding builds a padded Encoding from a 32-byte alphabet of unique byte values that must not include CR or LF.
WithPadding returns a copy that uses a different padding rune, or NoPadding.
Encode, decode, and streams
Encode writes the encoded form of src into dst.
Encode writes padded output in 8-byte chunks, so it is not appropriate on individual blocks from a large data stream. Use NewEncoder instead.
EncodeToString returns the base32 encoding of src.
NewEncoder returns a stream encoder; data written to it is encoded and written to the underlying writer.
Because encodings work in 5-byte blocks, the caller must Close the encoder to flush a partial block.
NewDecoder constructs a stream decoder.
CorruptInputError is the error type for corrupt input.
See also
Claims
- id: C1 claim: The package implements RFC 4648 base32 encoding. source: S2 evidence: "Package base32 implements base32 encoding as specified by RFC 4648"
- id: C2 claim: StdEncoding is the standard RFC 4648 base32 alphabet. source: S2 evidence: "StdEncoding is the standard base32 encoding, as defined in RFC 4648"
- id: C3 claim: HexEncoding is the RFC 4648 extended hex alphabet, often used in DNS. source: S1 evidence: "HexEncoding is the \"Extended Hex Alphabet\" defined in RFC 4648"
Sources
- [S1] base32 package - encoding/base32. The Go Authors. https://pkg.go.dev/encoding/base32 . License: BSD-3-Clause. Accessed 2026-11-27.
- [S2] base32.go (source). The Go Authors. https://go.dev/src/encoding/base32/base32.go . License: BSD-3-Clause. Accessed 2026-11-27.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, base32 package - encoding/base32; The Go Authors, base32.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, base32 package - encoding/base32; The Go Authors, base32.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go encoding/base32: RFC 4648 encodings, including the hex alphabet." iinventedlight Library, iil:note:j07x636b, version of 2026-11-27. https://iinventedlight.com/library/notes/go-encoding-base32/. License: CC-BY-4.0.
@misc{iil_note_j07x636b,
author = {{iinventedlight}},
title = {{Go encoding/base32: RFC 4648 encodings, including the hex alphabet}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-27},
url = {https://iinventedlight.com/library/notes/go-encoding-base32/},
note = {Permanent ID iil:note:j07x636b. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-encoding-base32.schema.json (schema; CC-BY-4.0)
- go-encoding-base32.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-encoding-base32.md.