<commit_before>package default_package;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.KeySpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.SecretKeySpec;
import javax.swing.JOptionPane;

public class AES
{
  static String filePath;


  static String pass;
  static Key key;
  static boolean isShread;
  
  public AES(String filePath, String pass) throws UnsupportedEncodingException, NoSuchAlgorithmException, Exception
  {
    AES.filePath = filePath.replace("\\", "/");
    AES.pass = pass;
    key = keyGen(hash(pass));
  }
  /*
   * AES constructor for shred only
   */
  public AES(String filePath, boolean isShread)
    throws UnsupportedEncodingException, NoSuchAlgorithmException, Exception
  {
    AES.filePath = filePath;
    AES.isShread = isShread;
    SecureRandom rand = new SecureRandom(SecureRandom.getSeed((int)System.currentTimeMillis()));
    key = keyGen(hash(String.valueOf(rand.nextLong())));
  }
  
  private static byte[] getFile() {
    VoidFile f = new VoidFile(filePath);
    InputStream is = null;
    try {
      is = new FileInputStream(f);
    }
    catch (FileNotFoundException e2) {
      e2.printStackTrace();
    }
    byte[] content = null;
    try {
      content = new byte[is.available()];
    }
    catch (IOException e1) {
      e1.printStackTrace();
    }
    try {
      is.read(content);
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    
    return content;
  }
  
  public static void encrypt() throws Exception {
    byte[] encrypted = null;
    byte[] content = getFile();
    for (int x = 0; x < 1000; x++) {
      
      try
      {
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(1, key);
        encrypted = cipher.doFinal(content);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    saveFile(encrypted);
    
    if (!isShread) {
      JOptionPane.showMessageDialog(null, "Encryption complete");
    } else {
      JOptionPane.showMessageDialog(null, "Shread complete");
    }
    isShread = false;
  }
  
  public static void decrypt() throws Exception
  {
    byte[] decrypted = null;
    for (int x = 0; x < 1000; x++) {
      byte[] textCryp = getFile();
      try
      {
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(2, key);
        decrypted = cipher.doFinal(textCryp);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    saveFile(decrypted);
    JOptionPane.showMessageDialog(null, "Decryption complete");
  }
  
  private static void saveFile(byte[] bytes) throws IOException {
	VoidFile vf = new VoidFile(filePath);
    FileOutputStream fos = new FileOutputStream(filePath);
    fos.write(bytes);
    fos.close();<commit_msg>Fixed a bug, now encryption actually runs 1000 times<commit_after>package default_package;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.KeySpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.SecretKeySpec;
import javax.swing.JOptionPane;

public class AES
{
  static String filePath;


  static String pass;
  static Key key;
  static boolean isShread;
  
  public AES(String filePath, String pass) throws UnsupportedEncodingException, NoSuchAlgorithmException, Exception
  {
    AES.filePath = filePath.replace("\\", "/");
    AES.pass = <PASSWORD>;
    key = keyGen(hash(pass));
  }
  /*
   * AES constructor for shred only
   */
  public AES(String filePath, boolean isShread)
    throws UnsupportedEncodingException, NoSuchAlgorithmException, Exception
  {
    AES.filePath = filePath;
    AES.isShread = isShread;
    SecureRandom rand = new SecureRandom(SecureRandom.getSeed((int)System.currentTimeMillis()));
    key = keyGen(hash(String.valueOf(rand.nextLong())));
  }
  
  private static byte[] getFile() {
    VoidFile f = new VoidFile(filePath);
    InputStream is = null;
    try {
      is = new FileInputStream(f);
    }
    catch (FileNotFoundException e2) {
      e2.printStackTrace();
    }
    byte[] content = null;
    try {
      content = new byte[is.available()];
    }
    catch (IOException e1) {
      e1.printStackTrace();
    }
    try {
      is.read(content);
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    
    return content;
  }
  
  public static void encrypt() throws Exception {
    byte[] encrypted = null;
    byte[] content = getFile();
    for (int x = 0; x < 1000; x++) {
      
      try
      {
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(1, key);
        encrypted = cipher.doFinal(content);
        content = encrypted;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    saveFile(encrypted);
    
    if (!isShread) {
      JOptionPane.showMessageDialog(null, "Encryption complete");
    } else {
      JOptionPane.showMessageDialog(null, "Shread complete");
    }
    isShread = false;
  }
  
  public static void decrypt() throws Exception
  {
    byte[] decrypted = null;
    byte[] textCryp = getFile();
    for (int x = 0; x < 1000; x++) {
      try
      {
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(2, key);
        decrypted = cipher.doFinal(textCryp);
        textCryp = decrypted;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    saveFile(decrypted);
    JOptionPane.showMessageDialog(null, "Decryption complete");
  }
  
  private static void saveFile(byte[] bytes) throws IOException {
	VoidFile vf = new VoidFile(filePath);
    FileOutputStream fos = new FileOutputStream(filePath);
    fos.write(bytes);
    fos.close();
{'fraction_non_alphanumeric': 0.11231995096536929, 'fraction_numerical': 0.006129328838492185, 'mean_word_length': 3.1076148521082443, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3417064', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1967, 'n_words': 461}