This C program provides a simple file encryption and decryption tool using the XOR cipher. The XOR cipher is a basic symmetric key algorithm that operates by bitwise XORing each byte of the plaintext with a corresponding byte of the key.
Note: We are re-creating the utility in Rust to leverage Memory-safety, and With the rust implementation, we will be incorporating more encryption algorithms.
Compile the program using build script (GCC): ( Make sure the script has appropriate permission for execution )
./build.sh -bc
Run the program with the desired options:
-
To encrypt a file:
./cread -e <filename> -o <output_filename>
-
To decrypt a file:
./cread -d <filename> -o <output_filename>
-
To see the help message:
./cread --help
-e, --encrypt
: Encrypt the specified file with a passphrase.-d, --decrypt
: Decrypt the specified file with a passphrase.-o, --output
: Specify the output file. If not provided, the program will create a file with a .enc extension.--help
: Display the help message.
-
Encrypt a file:
./cread -e file.txt -o encrypted.txt
-
Decrypt a file:
./cread -d encrypted.txt -o decrypted.txt
- The user is prompted to enter a passphrase.
- The program reads the input file and XORs each byte with the corresponding byte from the passphrase.
- The encrypted data is written to the output file.
- The user is prompted to enter the passphrase used for encryption.
- The program reads the encrypted file and XORs each byte with the corresponding byte from the passphrase.
- The decrypted data is written to the output file.
- The program supports reading from and writing to files, and it can also use standard input/output.
- If the output file is not provided for encryption, the program appends ".enc" to the input file and creates a new encrypted file.
- If the output file is not provided for decryption, the output will be shown to the console.
- The program checks for valid combinations of options and provides error messages accordingly.
- The XOR key used for encryption and decryption is derived from the passphrase.
- Currently, the program uses a basic XOR cipher. Future scope will be to enhance security by incorporating a more robust encryption algorithm.
- Implement password hashing to securely store and verify passphrases.