import java.io.*;
import java.util.Scanner;

public class QuackCryptor{

    public static void main(String[] args) {

        if (args.length != 2) {
            System.out.println("Usage: java quackcryption [encrypt, decrypt] [file.txt]");
            return;
        }

        Scanner scan;
        PrintWriter writer;
        String command = args[0];
        String fileName = args[1];
        String temp;
        String temp2;

        if (command.equalsIgnoreCase("encrypt")) {
            try {
                System.out.println("File: " + fileName);
                File file = new File(fileName);
                //scan = new Scanner(file);
                FileInputStream fis = new FileInputStream(file);
                int bytes = fis.available();
                writer = new PrintWriter("quacked.quack", "UTF-8");
                String header = Headers.makeHeader(fileName);
                writer.print(header);

                int b;
                for (int x = 0; x < bytes; x++) {
                    System.out.println(b = fis.read());
                    temp = AES.encrypt("QuackQuackQuack!", "RandomInitVector", ((char) b) + "");
                    System.out.println(temp);
                    temp2 = Quack.quackCrypt(temp);
                    writer.print(temp2);
                }
                fis.close();
                /*while(scan.hasNextByte()) {
                    System.out.println("Found a byte!");
                    temp = AES.encrypt("QuackQuackQuack!", "RandomInitVector", ((char) scan.nextByte()) + ""); //converts current byte to AES
                    temp2 = Quack.quackCrypt(temp);
                    writer.print(temp2);
                }*/
                writer.close();

            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (command.equalsIgnoreCase("decrypt")) {
            try {
                System.out.println("File: " + fileName);
                File file = new File(fileName);
                scan = new Scanner(file);
                if (!(scan.next().equals("quackquAck"))) {
                    System.out.println("Inputted file is not encrypted with QuackCryption");
                    return;
                }
                String header = "";
                for (int x = 0; x < 255; x++) {
                    header += scan.next();
                    if (x != 254)
                        header += " ";
                }
                String name = Headers.decryptHeader(header);
                System.out.println("name is: " + name);
                String quacks = "";
                while (scan.hasNext()) {
                    quacks+= scan.next();
                }
                String decrypted = "";
                String singleAes = "";
                String quackquack = "quackquack";
                for (int x = 0;  < quacks.length(); ) {
                    singleAes = Quack.quackReader(quacks.substring(x, x+10));
                    decrypted += AES.decrypt("QuackQuackQuack!", "RandomInitVector", singleAes);
                }
                /*
                String aes = Quack.quackReader(quacks);
                String endString = "";
                for (int x = 0; x < 1000; x++) {

                    aes = AES.decrypt("QuackQuackQuack!", "RandomInitVector", aes);
                }
                */
                File output = new File("icon.jpg");
                FileOutputStream fos = new FileOutputStream(output);
                System.out.println(aes);
                for (int i = 0; i < aes.length(); i++) {
                    System.out.println("50");
                    fos.write(aes.charAt(i));
                }
                fos.close();
                return;
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            System.out.println("Usage: java quackcryption [encrypt, decrypt] [file.txt]");
            return;
        }
    }
}
@@ -949,16 +949,55 @@
  int b;%0A
+                String toEncrypt = %22%22;%0A
         
@@ -1106,32 +1106,70 @@
                 
+toEncrypt += b;%0A                    /*
 temp = AES.encry
@@ -1359,32 +1359,34 @@
 er.print(temp2);
+*/
 %0A               
@@ -1380,32 +1380,204 @@
               %7D%0A
+                temp = AES.encrypt(%22QuackQuackQuack!%22, %22RandomInitVector%22, toEncrypt);%0A                temp2 = Quack.quackCrypt(temp);%0A                writer.print(temp2);%0A
                 
@@ -2928,16 +2928,17 @@
   quacks
+ 
 += scan.
@@ -2947,241 +2947,64 @@
 xt()
-;%0A                %7D%0A                String decrypted = %22%22;%0A                String singleAes = %22%22;%0A                String quackquack = %22quackquack%22;%0A                for (int x = 0;  %3C quacks.length(); ) %7B%0A                    singleAes
+ + %22 %22;%0A                %7D%0A                String toUnAES
  = Q
@@ -3030,27 +3030,8 @@
 acks
-.substring(x, x+10)
 );%0A 
@@ -3049,23 +3049,22 @@
     
-    decrypte
+String unAES
 d 
-+
 = AE
@@ -3117,17 +3117,15 @@
 r%22, 
-singleAes
+toUnAES
 );%0A 
@@ -3131,33 +3131,61 @@
                 
-%7D
+System.out.println(unAESd);%0A%0A
 %0A               
@@ -3583,32 +3583,34 @@
                 
+/*
 System.out.print
@@ -3830,32 +3830,51 @@
         return;%0A
+                */%0A
             %7D ca

SAVE ME SENPAI