Skip to content

base64

10 commands

Encodes and decodes Base64, the standard way to carry binary data over text channels — common in tokens, config files and shell file-transfer tricks.

  • encoding
  • base64
  • data transfer

Install base64

sudo apt install coreutils

Encoding3

echo -n "<text>" | base64

Encodes text to Base64. -n stops echo adding a newline that would change the output.

Link
base64 <file>

Encodes a file, for example to paste a binary over a text-only channel.

Link
base64 -w 0 <file>

Encodes with no line wrapping — needed when the receiver expects a single line (GNU).

Link

Decoding3

echo "<b64>" | base64 -d

Decodes Base64 back to text. On macOS use -D.

Link
base64 -d <file> > <out>

Decodes a file.

Link
echo "<b64>" | base64 -d | xxd | head

Decodes and inspects bytes — ELF starts with 7f 45 4c 46, PNG with 89 50 4e 47.

Link

Transfer trick1

base64 -w 0 <file>; # then on target: echo <b64> | base64 -d > <file>

Moves a file to a host with only a shell: encode here, paste and decode there.

Link