LinuxCommandLibrary

base32

Encode or decode base32 data

TLDR

Encode a file

$ base32 [path/to/file]
copy

Wrap encoded output at a specific width (0 disables wrapping)
$ base32 [[-w|--wrap]] [0|76|...] [path/to/file]
copy

Decode a file
$ base32 [[-d|--decode]] [path/to/file]
copy

Encode from stdin
$ [command] | base32
copy

Decode from stdin
$ [command] | base32 [[-d|--decode]]
copy

SYNOPSIS

base32 [OPTION]... [FILE]
base32 -d [OPTION]... [FILE]

PARAMETERS

-d, --decode
    Decode data instead of encoding

-e, --encode
    Encode data (default behavior)

-i, --ignore-garbage
    Ignore non-alphabet characters during decoding

-s, --size
    Process partial final lines during decoding

-w, --wrap=COLS
    Wrap lines after COLS characters (default: 76, 0 to disable)

--help
    Display help and exit

-V, --version
    Output version information and exit

DESCRIPTION

The base32 command is a utility from GNU coreutils for converting binary data to and from Base32 encoding, as defined in RFC 4648. Base32 uses a 32-character alphabet (A-Z and 2-7) to represent binary data in a compact, ASCII-safe text format, with padding using '=' characters. This makes it ideal for scenarios where binary files must be transmitted or stored in text-only environments, such as email, DNS, or configuration files.

By default, base32 reads from standard input or specified files and encodes to standard output, wrapping lines at 76 characters. Use -d or --decode to reverse the process. It handles partial input lines gracefully during decoding (ignoring them unless -s is used) and can skip garbage characters with -i.

Compared to Base64, Base32 produces slightly larger output (~160% of original size vs. ~133%) but offers case-insensitivity and error detection benefits due to its restricted alphabet. Common use cases include embedding images in scripts, secure key representation, or URL-safe data transfer. Always verify output integrity after decoding, as malformed input may produce garbage.

CAVEATS

Decoding ignores partial lines by default unless -s; output size grows ~160% on encoding; no built-in integrity checks—verify manually.

EXAMPLES

base32 myfile.bin > myfile.b32
base32 -d myfile.b32 > myfile.bin
echo -n 'Hello' | base32 # Outputs: JBSWY3DP

STANDARDS

Follows RFC 4648 (no padding variant available); uses uppercase letters and digits 2-7.

HISTORY

Added to GNU coreutils in version 8.0 (January 2010) as a companion to base64(1), implementing RFC 4648 Base32 for modern text-encoding needs.

SEE ALSO

base64(1), base16(1), uuencode(1), xxd(1)

Copied to clipboard