The Encryption-Decryption Project is a implementation of the encryption and decryption of data which is provided.
In this project if we provide the data (combination of all unocide characters) along with the operation (Encryption or Description) then it output the result accordingly. All the command are given at command line arguments while running the project.
Design Pattern which I have used in this project is Factory Design Pattern
Lets break it down
- input data drectly
-data "Welcome to hyperskill!"
- input the file name through which we have to access data
-in road_to_treasure.txt
- If there is no -data and no -in the program should assume that the data is an empty string;
- If there are both -data and -in arguments, your program should prefer -data over -in.
- If we want to get the encription of provided data
-mode enc
- If we want to get the decription of provided data
-mode dec
If there is no -mode, the program should work in the enc mode;
Key is the value which define number of shifting which we have to do for characters in data.
For providing Key
-key 5
- If there is no -key, the program should consider that key is 0;
There are two ways in which we can do encrytion and decryption of data provided. Either we can do shifting only on 26 alphabets or we can do shiting for all 95 unicode characters.
- If we want to do shifting on only 26 alphabets then arguments provide would be
-alg shift
It shift alphabets between a to z within itself. Similarly for A to Z For instance: if character = 'a' and key = 5 then it shift to 'f'
- If we want to do shifting on all 95 unicode characters
-alg unicode
Data, key and operation are provided, now we also have to specify where we have to output result.
Either we can print the output or can save the output to some file. For saving in the file we need the file name, which is prvided in this way
-out protected.txt
-out is the argument and protected.txt is the parameter
- If there is no -out argument, the program must print data to the standard output;
First compile the program
javac Encryption-Decryption (Java)
While running the program input the command line arguments as well. Following is the format of giving arguments
java file_name arg1 para1 arg2 para2 arg3 para3 ....
- -mode: it specify what operation we want to perform, it can be either encryption or decryption. For Encrytion
-mode enc
For Decryption
-mode dec
- -in: it tells the file name from where we have to take input
-in road_to_treasure.txt
- out: it tells the name to file to which we have to paste the result
-out road_to_treasure.txt
- -data: It tells about the data
-data "Welcome to hyperskill!"
- -key: It specify the value of key
-key 5
- -alg: It specifies which algorithm to select. Either shifting via 26 alphabets or via all 95 unicode characters.
-alg shift
-alg unicode
So at last while running code we can provide these arguments as mentioned below
Encryption with the unicode algorithm
java file_name -mode enc -key 5 -data "Welcome to hyperskill!" -alg unicode
Output:
\jqhtrj%yt%m~ujwxpnqq&
Decryption with the unicode algorithm
java file_name -key 5 -alg unicode -data "\jqhtrj%yt%m~ujwxpnqq&" -mode dec
Output:
Welcome to hyperskill!
Encryption with the shift algorithm
java file_name -key 5 -alg shift -data "Welcome to hyperskill!" -mode enc
decryption with the shift algorithm
-key 5 -alg shift -data "Bjqhtrj yt mdujwxpnqq!" -mode dec
Output: Welcome to hyperskill!