diff --git a/.idea/misc.xml b/.idea/misc.xml
index a165cb3..1bb046f 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index a0733a5..f857c90 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/project.iml b/.idea/project.iml
deleted file mode 100644
index 47baa8c..0000000
--- a/.idea/project.iml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/crypto/Crypto.java b/src/crypto/Crypto.java
index 51d57b7..8801801 100644
--- a/src/crypto/Crypto.java
+++ b/src/crypto/Crypto.java
@@ -1,10 +1,84 @@
package crypto;
-
import java.util.Scanner;
-
+import java.io.*;
public class Crypto {
+ private static void encryption(String message, int key, String out) {
+ char let;
+ char let2;
+ StringBuilder str = new StringBuilder(message);
+ for (int i=0; i0){
+ File file = new File(out);
+ try(FileWriter writer = new FileWriter(file)){
+ writer.write(str.toString());
+ } catch (IOException e){
+ System.out.println("The file can not be opened: " + out);
+ }
+
+ }
+ else System.out.println(str);
+ }
+ private static void decryption(String message, int key, String out) {
+ char let;
+ char let2;
+ StringBuilder str = new StringBuilder(message);
+ for (int i=0; i0){
+ File file = new File(out);
+ try(FileWriter writer = new FileWriter(file)){
+ writer.write(str.toString());
+ } catch (IOException e){
+ System.out.println("The file can not be opened: " + out);
+ }
+
+ }
+ else System.out.println(str);
+ }
+
public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // write your code here
+ Scanner scan = new Scanner(System.in);
+ String message="", target;
+ int key;
+ int kostil=0;
+ String out="";
+ int indTarget=-1, indMessage=-1, indKey=-1, indIn=-1, indOut=-1;
+ for (int i=0; i=0) target=args[indTarget+1];
+ else target="enc";
+ if (indKey>=0) key=Integer.valueOf(args[indKey+1]);
+ else key = scan.nextInt();
+
+ if (indIn>=0) {
+ File in = new File(args[indIn+1]);
+ try(Scanner scanner = new Scanner(in)){
+ message = scanner.nextLine();
+ } catch (FileNotFoundException e){
+ System.out.println("File is not found: " + in);
+ message=scan.nextLine();
+ }
+ }
+ if (message.length()>0) kostil++;
+ else if (indMessage >=0 ) message = args[indMessage+1];
+ else message=scan.nextLine();
+ if (indOut>=0) {
+ out =args[indOut+1];
+ }
+ System.out.println(out);
+ if (target.equals("enc") || target.equals("")) encryption(message, key, out);
+ else decryption(message, key, out);
+
}
-}
+}
\ No newline at end of file