A minimal command-line utility written in C that performs file encryption and decryption using a Caesar cipher (shift of 3).
This project demonstrates a basic implementation of file-based encryption.
- Encrypts text using a Caesar cipher (+3 shift)
- Decrypts text using a Caesar cipher (-3 shift)
- Preserves uppercase and lowercase letters
- Leaves non-alphabet characters unchanged
.
├── encrypt.c
├── encrypt.exe
├── data.txt
├── secret.txt
├── output.txt
gcc encrypt.c -o encrypt./encrypt <mode> <inputfile> <outputfile>| Argument | Description |
|---|---|
mode |
E for encryption, D for decryption |
inputfile |
Path to the input file |
outputfile |
Path to the output file |
./encrypt E data.txt secret.txt./encrypt D secret.txt output.txtInput (data.txt)
Hello! My name is Johan.
Encrypted (secret.txt)
Khoor! Pb qdph lv Mrkdq.
Decrypted (output.txt)
Hello! My name is Johan.
The program reads the file character-by-character and applies transformations:
-
Uppercase letters:
- Encryption:
(ch - 'A' + 3) % 26 + 'A' - Decryption:
(ch - 'A' - 3 + 26) % 26 + 'A'
- Encryption:
-
Lowercase letters:
- Encryption:
(ch - 'a' + 3) % 26 + 'a' - Decryption:
(ch - 'a' - 3 + 26) % 26 + 'a'
- Encryption:
-
Other characters are unchanged
This project uses a Caesar cipher, which is not secure and is intended for educational purposes only.
Do not use this for protecting sensitive information.
- Add custom shift value
- Support binary files
- Add password-based encryption
- Implement stronger algorithms (AES, XOR)
- Improve error handling
- Build a GUI
Johan