---
name: "bencode"
section: "1"
platform: "linux"
package: "cnews"
version: "cr.g7-31"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/bencode"
---

# bencode(1)

encode a binary file into printable ASCII; decode it back into binary.

## NAME

bencode, bdecode - encode a binary file into printable ASCII; decode it back into binary.

## SYNOPSIS

**bencode \[source\]**\
 **bdecode \[source\]**

## DESCRIPTION

*Bencode* is used to a encode a binary file into printable ASCII, and *bdecode* is used to decode an encoded file back into binary. These functions are typically used to package a binary file for mailing.

*Bencode* takes the named source file (the default is standard input) and produces an encoded version on the standard output. The encoding uses only the ASCII characters \`\`A'' - \`\`Z'', \`\`a'' - \`\`z'', \`\`0'' - \`\`9'', \`\`+'', and \`\`-''. The ASCII characters blank, newline, and \`\`/'' also appear in the encoded file, but do not represent encoded bits. The encoded file is terminated with a byte count and cyclic redundancy check for detecting corrupted files.

*Bdecode* reads a file encoded by bencode (the default is standard input), strips off any leading and trailing lines added by mailers, and writes the decoded version to standard output.

These functions are similar to *uuencode* and *uudecode,* but are more robust because of the CRC check and because they don't send characters like \`\`^'' and \`\`\\'', which are likely to get mangled if the file should happen to pass through a non-ASCII machine.

## SEE ALSO

[uuencode(1)](/uuencode/1.md)

## AUTHORS

Ken Lalonde and Reg Quinton

## BUGS

The file is expanded by 35% (3 bytes become 4 plus control information) causing it to take longer to transmit.
