-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Main class created. UML class diagram added. input.txt and output.txt added for passing arguments
- Loading branch information
1 parent
2653bd0
commit 39de112
Showing
5 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package client; | ||
|
||
import factory.AlgFactory; | ||
import model.AlgBase; | ||
|
||
import java.io.File; | ||
|
||
public class Main { | ||
public static void main(String[] args) throws Exception { | ||
String mode = "enc"; | ||
String alg = "shift"; | ||
StringBuilder msg = new StringBuilder(); | ||
int key = 0; | ||
File outputFile = null; | ||
File inputFile = null; | ||
|
||
for (int i = 0; i < args.length; i += 2) { | ||
switch (args[i]) { | ||
case "-mode": | ||
mode = args[i + 1]; | ||
break; | ||
case "-key": | ||
key = Integer.parseInt(args[i + 1]); | ||
break; | ||
case "-data": | ||
msg.append(args[i + 1]); | ||
break; | ||
case "-in": | ||
if ("".equals(msg.toString())) { | ||
inputFile = new File(args[i + 1]); | ||
} | ||
break; | ||
case "-out": | ||
outputFile = new File(args[i + 1]); | ||
outputFile.createNewFile(); | ||
break; | ||
case "-alg": | ||
alg = args[i + 1]; | ||
break; | ||
} | ||
} | ||
|
||
AlgBase algorithm = AlgFactory.createAlgorithm(alg, msg.toString(), mode, key); | ||
if ("enc".equals(mode)) { | ||
algorithm.encrypt(inputFile, outputFile); | ||
} else { | ||
algorithm.decrypt(inputFile, outputFile); | ||
} | ||
} | ||
} |
Empty file.