Skip to content

clark91/FileTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileTools

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.


Features

Core File Operations

  • 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.


Additional Operations

  • 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 in log.txt.


Encryption and Decryption

  • Encrypt File
    -enc <filename>

  • Decrypt File
    -dec <filename>

How It Works

  • 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.


Compiling the Program

Encryption and decryption require the OpenSSL library.

Compile using gcc:

gcc -o fileTools Main.c -lcrypto

Usage

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

About

File Tools in C

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors