A simple C++ console application to encrypt and decrypt files using a password.
- File Encryption: Encrypts any file using a custom password
- File Decryption: Decrypts previously encrypted files
- Algorithm: Uses a combination of XOR encryption and bitwise rotation for basic data obfuscation
EncryptorDecryptor/
├── CMakeLists.txt # CMake build configuration
├── configuration/
│ ├── build.bat # Build script
│ └── run.bat # Run script
├── artifacts/
│ └── clean.bat # Clean build files
└── src/
├── main.cpp # Main program entry point
├── CryptoUtils.cpp # Key generation utilities
├── CryptoUtils.h
├── Encryptor.cpp # Encryption/decryption logic
├── Encryptor.h
├── FileManager.cpp # File I/O operations
└── FileManager.h
-
CMake (version 3.10 or higher)
- Download: https://cmake.org/download/
- Add to system PATH during installation
-
C++ Compiler supporting C++17 or later
- MinGW-w64 (for Windows): https://sourceforge.net/projects/mingw-w64/
- GCC (for Linux):
sudo apt install build-essential cmake
-
Windows OS (for the provided batch scripts)
From the project root directory:
configuration\build.batThis will:
- Check for CMake and g++ compiler
- Create a
builddirectory - Configure the project with CMake
- Compile the source code
- Generate executable at
build/bin/EncryptorDecryptor.exe
configuration\run.batOr directly:
build\bin\EncryptorDecryptor.exeartifacts\clean.bat# Create and enter build directory
mkdir build
cd build
# Configure project
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
# Build
cmake --build . --config Release
# Return to root
cd ..
# Run
build\bin\EncryptorDecryptor.exe# Create build directory
mkdir build
# Compile
g++ -std=c++17 -O2 -Wall -Wextra -I./src ^
src/CryptoUtils.cpp ^
src/Encryptor.cpp ^
src/FileManager.cpp ^
src/main.cpp ^
-o build/EncryptorDecryptor.exe
# Run
build\EncryptorDecryptor.exe-
Run the executable:
build\bin\EncryptorDecryptor.exe
-
Choose operation:
1. Encrypt File 2. Decrypt File Choice: 1 -
Provide file paths:
Input File: document.txt Output File: document.txt.enc Password: mySecretPassword123 -
Success message:
Operation successful.
build\bin\EncryptorDecryptor.exe
1 # Choose encrypt
myfile.txt # Input file
myfile.encrypted # Output file
myPassword123 # Passwordbuild\bin\EncryptorDecryptor.exe
2 # Choose decrypt
myfile.encrypted # Input file
myfile_decrypted.txt # Output file
myPassword123 # Same password used for encryptionThe project uses CMake with the following settings:
- C++ Standard: C++17
- Compiler Warnings: Enabled (
-Wall -Wextra -Wpedantic) - Build Type: Release (optimized)
- Output Directory:
build/bin/
- Install CMake from https://cmake.org/download/
- Add CMake to system PATH
- Restart terminal/command prompt
- Install MinGW-w64
- Add MinGW
binfolder to system PATH (e.g.,C:\mingw64\bin) - Restart terminal/command prompt
- Check if input file exists
- Verify file path is correct
- Ensure you have read permissions
- Check if output directory exists
- Verify you have write permissions
- Ensure output file is not open in another program