← All notes

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

Sources

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

Permanent ID: iil:note:j07x636b

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.},
}

Markdown

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.

All artifact files (JSON index)

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.