LinuxCommandLibrary

caesar

Encrypt or decrypt text using Caesar cipher

SYNOPSIS

caesar [shift] [file ...]

PARAMETERS

shift
    Integer positions to shift alphabet (default: 13). Negative for decoding. Modulo 26.

file
    Input file(s) to process. Multiple allowed. Omits reads from stdin.

DESCRIPTION

The caesar command implements a simple substitution cipher, shifting alphabetic characters by a specified number of positions in the alphabet. By default, it uses a shift of 13 positions, known as ROT13, which is self-inverse—applying it twice returns the original text. This makes it useful for basic text obfuscation, such as hiding spoilers in emails or forum posts.

Letters wrap around the alphabet (A shifts to N with +13, Z to M), preserving case: uppercase stays uppercase, lowercase stays lowercase. Non-alphabetic characters (numbers, punctuation, spaces) remain unchanged. The shift value is taken modulo 26, so values outside 1-25 are normalized. Negative shifts decode forward shifts.

Input is read from standard input or specified files, with output to stdout. It's a lightweight tool from BSD utilities, ideal for quick encoding/decoding in scripts or command lines. Not suitable for security due to easy reversal.

CAVEATS

Handles only ASCII A-Z/a-z; ignores others. No Unicode support. Trivial to crack—not for encryption.

EXAMPLES

caesar 13 < input.txt
echo 'Hello' | caesar 3
caesar -13 file.txt > decoded.txt

HISTORY

Derived from ancient Roman cipher used by Julius Caesar. Linux caesar from BSD games/mainutils (1980s), popularized in Unix fun tools.

SEE ALSO

rot13(1), tr(1)

Copied to clipboard