basenc

basenc is the general encoding command. Where base32 and base64 each do one encoding, basenc does many — the encoding is chosen by an option.

basenc encoding [options] [file]
$ echo Peios | basenc --base16
5065696F730A

Every run of basenc must name an encoding. With no file, it reads standard input.

The encodings #

OptionEncoding
--base64Standard base64 — the same as the base64 command.
--base64urlBase64 with a file- and URL-safe alphabet.
--base32Standard base32 — the same as the base32 command.
--base32hexBase32 with the extended-hex alphabet.
--base16Hexadecimal.
--base2msbfA bit string, most-significant bit first.
--base2lsbfA bit string, least-significant bit first.
--z85A compact, ASCII85-style encoding. When encoding, the input length must be a multiple of 4; when decoding, a multiple of 5.
--base58Base58 — an alphabet chosen so its characters are not visually confusable.

Options #

By default basenc encodes. These options apply to whichever encoding you chose:

OptionEffect
-d, --decodeDecode instead of encode.
-i, --ignore-garbageWhen decoding, skip characters that are not part of the alphabet.
-w, --wrap=COLSWhen encoding, wrap output to lines of COLS characters. -w 0 disables wrapping.

basenc and the dedicated commands #

For plain base64 or base32, base64 and base32 are the shorter way to ask. Use basenc when you need an encoding the dedicated commands do not offer — hex, URL-safe base64, the bit-string forms, z85, or base58.

Exit status #

CodeMeaning
0Success.
1No encoding was named, a file could not be read, or the input was not valid for the chosen encoding.

Edit this page