diff --git a/src/crypto/Crypto.java b/src/crypto/Crypto.java index 51d57b7..8dd7fa0 100644 --- a/src/crypto/Crypto.java +++ b/src/crypto/Crypto.java @@ -1,10 +1,37 @@ -package crypto; - -import java.util.Scanner; - public class Crypto { public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - // write your code here + // File file = new File(args[7]); + // Scanner scanner = new Scanner(file); + String mode ="dec"; + String comm = "in"; + String data = "data"; + if(args[4].equals(data)){ + char[] dataText = args[5].toCharArray(); + int keyNumber = Integer.parseInt(args[3]); + + if (args[1].equals(mode)){ + for (int x = 0; x < dataText.length; x = x + 1) { + int y = (int)dataText[x]-keyNumber; + System.out.print((char)y); + } + } + }else { + File file = new File(args[5]); + Scanner scanner = new Scanner(file); + String data1 = scanner.nextLine(); + char[] dataText = data1.toCharArray(); + int keyNumber = Integer.parseInt(args[3]); + + if (args[1].equals(mode)){ + for (int x = 0; x < dataText.length; x = x + 1) { + int y = (int)dataText[x]-keyNumber; + System.out.print((char)y); + } + } + + } + + File file = new File(args[7]); + FileWriter writer = new FileWriter(file); } }