FileTools is a command-line utility written in C that provides a collection of file management and manipulation operations. It supports basic file handling, text manipulation, file comparison, logging, and password-based encryption/decryption.
-
Create File
-n <filename>...
Creates one or more new files with the specified names. -
Copy File
-cpy <source> <destination>
Copies the contents of a source file into a new destination file. -
Delete File
-df <filename>...
Deletes one or more files. -
Show File Contents
-o <filename>
Displays the contents of a file. -
Append Line
-a <filename> <text>
Appends a new line containing the specified text to the end of a file. -
Insert Line
-i <filename> <line> <text>
Inserts a line of text at a specified line number in a file. -
Delete Line
-dl <filename> <line>
Deletes a specific line from a file. -
Count Lines
-cl <filename>...
Displays the number of lines in each specified file.
-
Show Help
-h
Displays help information for the program. -
Rename File
-r <source> <destination>
Renames a file by copying it to a new file and deleting the original. -
Compare Files
-cmp <file1> <file2> ...
Compares files line by line. Differences are reported by line number.
When multiple files are supplied, each is compared against the first file. -
Show Change Log
-log
Displays the change log stored inlog.txt.
-
Encrypt File
-enc <filename> -
Decrypt File
-dec <filename>
- The user is prompted to enter a password.
- A 128-bit encryption key is derived from the password using PBKDF2 with:
- A randomly generated 128-bit salt
- SHA-256 as the hashing function
- The file contents are encrypted using a bitwise XOR cipher with the derived key.
- The encrypted file format is:
[16-byte salt][encrypted content]
- During decryption:
- The first 16 bytes are read as the salt
- The same key is regenerated using PBKDF2
- XOR is applied again to recover the original content
⚠ Important:
Decryption with an incorrect password is destructive. No integrity or password validation is performed.
Encryption and decryption require the OpenSSL library.
Compile using gcc:
gcc -o fileTools Main.c -lcryptoUsage
The program is operated entirely via command-line arguments.
Examples:
./fileTools -n file1.txt file2.txt
./fileTools -a notes.txt "New line of text"
./fileTools -cmp file1.txt file2.txt
./fileTools -enc secrets.txt