./caesar-cipher [-E|-e|-D|-d] [message_or_input_file] [-o output_file] [-k key]This program encrypts or decrypts text using the Caesar cipher. You can specify options via command-line flags or be prompted for missing values.
| Flag | Argument | Description |
|---|---|---|
-E |
[message] |
Encrypt mode. If followed by text, encrypts it directly. |
-D |
[message] |
Decrypt mode. If followed by text, decrypts it directly. |
-e |
[input_file] |
Encrypt mode. If followed by a file path, encrypts the file’s contents. |
-d |
[input_file] |
Decrypt mode. If followed by a file path, decrypts the file’s contents. |
-o |
output_file |
Specifies an output file to save the result. |
-k |
key (integer) |
Specifies the shift key (between 1-25) for the cipher. |
./caesar-cipher -E "hello world" -k 3Encrypts "hello world" with shift 3, outputs to stdout.
./caesar-cipher -d input.txt -k 5 -o decrypted.txtReads input.txt, decrypts using key 5, and writes to decrypted.txt.
./caesar-cipher -e -o encrypted.txtPrompts for the input file and shift key.
./caesar-cipher -E "hello" -kThe program will detect the missing key and prompt for it.
- If a required flag (
-kor input text) is missing, the user will be prompted. -Eand-D(uppercase) can take a message directly.-eand-d(lowercase) can take a file path.-oand-kmust be followed by an argument.
Make sure you have the following installed:
- CMake (version 3.10 or higher)
- A C++ compiler (GCC, Clang, MSVC, etc.)
Run the following command from the project root:
cmake -S . -B buildBuild the project with:
cmake --build buildThis will generate the executable caesar-cipher inside the build/ directory.
Once compiled, you can run the program like this:
./build/caesar-cipher [options]