This project is a simple command-line tool written in C that can encode and decode text using different algorithms. The tool currently supports two algorithms: a Caesar cipher (shift) and a Unicode-based shift (unicode).
To build the project, you need to have the following tools installed on your system:
make
gcc
(or any other C compiler)
To build the project, simply run the following command:
make
This will create an executable file called ncrypt
in the project directory.
The ncrypt tool can be used to encode or decode text using the shift or unicode algorithm. The program accepts several command-line arguments to specify the mode, key, input, and algorithm. The general syntax for the command is as follows:
./ncrypt -mode <mode> -key <key> [-data <data> | -in <input_file>] [-out <output_file>] -alg <algorithm>
The following table lists the available command-line arguments:
Argument | Description | Options |
---|---|---|
-mode | Encrypts/decrypts the message | enc (default), dec |
-data | Data that to be processed | Some text |
-in | Specify an input file to read from | e.g. file_in.txt |
-out | Specify a filename to write the result to | e.g. file_out.txt |
-alg | Select what algorithm should be used | shift (default), unicode |
- If there is no -mode, the program works in enc mode.
- If there is no -key, the program consider that key = 0.
- If there is no -data, and there is no -in the program assumes that the data is an empty string.
- If there is no -out argument, the program prints data to the standard output.
- If there are both -data and -in arguments, your program prefers -data over -in.
-
Encode with Shift Algorithm Encode the text "Hello, World" using a key of 3 with the Caesar shift algorithm:
./ncrypt -mode enc -key 3 -data "Hello, World" -alg shift
Output:
Khoor, Zruog
-
Decode with Unicode Algorithm Decode the text "Khoor, Zruog" using a key of 3 with the Unicode shift algorithm:
./ncrypt -mode dec -key 3 -data "Khoor, Zruog" -alg unicode
Output:
Hello, World
-
Encode with Unicode Algorithm Encode the text "Hello, World" using a key of 1 with the Unicode shift algorithm:
./ncrypt -mode enc -key 1 -data "Hello, World" -alg unicode
Output:
Ifmmp-!-Xpsme
-
Decode with Shift Algorithm Decode the text "Ifmmp-!-Xpsme" using a key of 1 with the Caesar shift algorithm:
./ncrypt -mode dec -key 1 -data "Ifmmp-!-Xpsme" -alg shift
Output:
Hello, World
-
Encode Text from a File and Output to a File Encode the contents of input.txt using the shift algorithm with a key of 5 and write the output to output.txt:
./ncrypt -mode enc -key 5 -in input.txt -out output.txt -alg shift
-
Decode Text from a File and Output to the Console Decode the contents of encoded.txt using the unicode algorithm with a key of 4 and print the result to the console:
./ncrypt -mode dec -key 4 -in encoded.txt -alg unicode
To remove the compiled executable and object files, run:
make clean
This will delete the ncrypt
executable and any object files created during the build process.
This project is licensed under the MIT License - see the LICENSE file for details.