Add files via upload

This commit is contained in:
ByteDream 2020-09-03 22:25:23 +02:00 committed by GitHub
parent 31bf88df1c
commit 55f2784ba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 3384 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,302 @@
package org.bytedream.cryptogx;
import javax.crypto.*;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* <p>Class for en- / decrypt text and files<p/>
*
* @since 1.0.0
*/
public class EnDecrypt {
public static class AES extends Thread {
public int iterations = 65536;
private final String secretKeyFactoryAlgorithm = "PBKDF2WithHmacSHA1";
private int keySize = 256;
private final String key;
private final byte[] salt;
public AES(String key, byte[] salt) {
this.key = key;
this.salt = salt;
}
public AES(String key, byte[] salt, int keySize) {
this.key = key;
this.salt = salt;
this.keySize = keySize;
}
public AES(String key, byte[] salt, int iterations, int keySize) {
this.key = key;
this.salt = salt;
this.iterations = iterations;
this.keySize = keySize;
}
/**
* <p>Creates a secret key from given (plain text) key and salt</p>
*
* @return the secret key
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*
* @since 1.0.0
*/
private byte[] createSecretKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
SecretKeyFactory factory = SecretKeyFactory.getInstance(secretKeyFactoryAlgorithm);
PBEKeySpec keySpec = new PBEKeySpec(key.toCharArray(), salt, iterations, keySize);
return factory.generateSecret(keySpec).getEncoded();
}
/**
* <p>Writes {@param inputStream} to {@param outputStream}</p>
*
* @param inputStream from which is written
* @param outputStream to which is written
* @param buffer
* @throws IOException
*
* @since 1.12.0
*/
private void write(InputStream inputStream, OutputStream outputStream, byte[] buffer) throws IOException {
int numOfBytesRead;
while ((numOfBytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, numOfBytesRead);
}
outputStream.close();
inputStream.close();
}
/**
* <p>Encrypts the {@param inputStream} to {@param outputStream}</p>
*
* @param inputStream that should be encrypted
* @param outputStream to which the encrypted {@param inputFile} should be written to
* @param buffer
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
* @throws InvalidKeyException
* @throws IOException
*
* @since 1.12.0
*/
public void encryptFile(InputStream inputStream, OutputStream outputStream, byte[] buffer) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IOException {
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher);
write(cipherInputStream, outputStream, buffer);
}
/**
* <p>Encrypts all files in the {@param inputDirectory} to the {@param outputDirectory}</p>
*
* @param inputDirectory that should be encrypted
* @param outputDirectory to which the encrypted {@param inputDirectory} files should be written to
* @param fileEnding get added to every file that gets encrypted (if the {@param fileEnding} starts and ends with
* a '@', the {@param fileEnding} will get removed from the file if it exists)
* @param buffer
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
* @throws InvalidKeyException
* @throws IOException
*
* @since 1.12.0
*/
public void encryptDirectory(String inputDirectory, String outputDirectory, String fileEnding, byte[] buffer) throws IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException {
AtomicBoolean remove = new AtomicBoolean(false);
if (fileEnding == null) {
fileEnding = "";
} else if (fileEnding.startsWith("@") && fileEnding.endsWith("@")) {
fileEnding = fileEnding.substring(1, fileEnding.length() - 1);
remove.set(true);
}
HashMap<File, File> files = new HashMap<>();
final String finalFileEnding = fileEnding;
Files.walk(Paths.get(inputDirectory)).map(Path::toFile).forEach(oldFile -> {
String oldFilePath = oldFile.getAbsolutePath();
if (oldFile.isDirectory()) {
new File(oldFilePath.replace(inputDirectory, outputDirectory + "/")).mkdir();
}else if (remove.get() && oldFilePath.endsWith(finalFileEnding)) {
files.put(oldFile, new File(oldFilePath.substring(0, oldFilePath.lastIndexOf(finalFileEnding))
.replace(inputDirectory, outputDirectory + "/") + finalFileEnding));
} else {
files.put(oldFile, new File(oldFilePath.replace(inputDirectory, outputDirectory + "/") + finalFileEnding));
}
});
File newFile;
for (Map.Entry<File, File> entry: files.entrySet()) {
newFile = entry.getValue();
encryptFile(new FileInputStream(entry.getKey()), new FileOutputStream(newFile), buffer);
}
}
/**
* <p>Decrypts the {@param inputStream} to {@param outputStream}</p>
*
* @param inputStream that should be decrypted
* @param outputStream to which the decrypted {@param inputFile} should be written to
* @param buffer
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
* @throws InvalidKeyException
* @throws IOException
* @throws InvalidAlgorithmParameterException
*
* @since 1.12.0
*/
public void decryptFile(InputStream inputStream, OutputStream outputStream, byte[] buffer) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IOException{
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
CipherOutputStream cipherOutputStream = new CipherOutputStream(outputStream, cipher);
write(inputStream, cipherOutputStream, buffer);
}
/**
* <p>Decrypts all files in the {@param inputDirectory} to the {@param outputDirectory}</p>
*
* @param inputDirectory that should be decrypted
* @param outputDirectory to which the decrypted {@param inputDirectory} files should be written to
* @param fileEnding get added to every file that gets decrypted (if the {@param fileEnding} starts and ends with
* a '@', the {@param fileEnding} will get removed from the file if it exists)
* @param buffer
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
* @throws InvalidKeyException
* @throws IOException
*
* @since 1.12.0
*/
public void decryptDirectory(String inputDirectory, String outputDirectory, String fileEnding, byte[] buffer) throws IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException {
AtomicBoolean remove = new AtomicBoolean(false);
if (fileEnding == null) {
fileEnding = "";
} else if (fileEnding.startsWith("@") && fileEnding.endsWith("@")) {
fileEnding = fileEnding.substring(1, fileEnding.length() - 1);
remove.set(true);
}
HashMap<File, File> files = new HashMap<>();
final String finalFileEnding = fileEnding;
Files.walk(Paths.get(inputDirectory)).map(Path::toFile).forEach(oldFile -> {
String oldFilePath = oldFile.getAbsolutePath();
if (oldFile.isDirectory()) {
new File(oldFilePath.replace(inputDirectory, outputDirectory + "/")).mkdir();
}
else if (remove.get() && oldFilePath.endsWith(finalFileEnding)) {
files.put(oldFile, new File(oldFilePath.substring(0, oldFilePath.lastIndexOf(finalFileEnding))
.replace(inputDirectory, outputDirectory + "/") + finalFileEnding));
} else {
files.put(oldFile, new File(oldFilePath.replace(inputDirectory, outputDirectory + "/") + finalFileEnding));
}
});
File newFile;
for (Map.Entry<File, File> entry: files.entrySet()) {
newFile = entry.getValue();
decryptFile(new FileInputStream(entry.getKey()), new FileOutputStream(newFile), buffer);
}
}
/**
* <p>Encrypt {@param bytes}</p>
*
* @param bytes that should be encrypted
* @return encrypted bytes
* @throws BadPaddingException
* @throws IllegalBlockSizeException
* @throws NoSuchPaddingException
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
* @throws InvalidKeyException
*
* @since 1.0.0
*/
public byte[] encrypt(byte[] bytes) throws BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException {
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
Cipher encryptCipher = Cipher.getInstance("AES");
encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey);
return encryptCipher.doFinal(bytes);
}
/**
* <p>Encrypt {@param bytes}</p>
*
* @param string that should be encrypted
*
* @see EnDecrypt.AES#encrypt(byte[])
*
* @since 1.0.0
*/
public String encrypt(String string) throws BadPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException, InvalidKeySpecException {
return Base64.getEncoder().encodeToString(encrypt(string.getBytes(StandardCharsets.UTF_8)));
}
/**
* <p>Decrypt encrypted {@param bytes}</p>
*
* @param bytes that should be decrypted
* @return decrypted bytes
* @throws BadPaddingException
* @throws IllegalBlockSizeException
* @throws NoSuchPaddingException
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
* @throws InvalidKeyException
*
* @since 1.12.0
*/
public byte[] decrypt(byte[] bytes) throws BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException {
Key secretKey = new SecretKeySpec(createSecretKey(), "AES");
Cipher decryptCipher = Cipher.getInstance("AES");
decryptCipher.init(Cipher.DECRYPT_MODE, secretKey);
return decryptCipher.doFinal(Base64.getDecoder().decode(bytes));
}
/**
* <p>Decrypt encrypted {@param string}</p>
*
* @param string that should be decrypted
*
* @see EnDecrypt.AES#decrypt(byte[])
*
* @since 1.0.0
*/
public String decrypt(String string) throws BadPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException, InvalidKeySpecException {
return new String(decrypt(string.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
}
}
}

View File

@ -0,0 +1,326 @@
/*
* @author bytedream
* @version 1.12.0
*
* Some <code>@since</code> versions may be not correct, because the <code>@since</code> tag got added in
* version 1.12.0 and I don't have all versions (1.0.0 - 1.11.0), so I cannot see when some methods were added
*/
package org.bytedream.cryptogx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.swing.*;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
/**
* <p>Main class<p/>
*
* @since 1.0.0
*/
public class Main extends Application {
protected static final int NON_PORTABLE = 1;
protected static final int PORTABLE = 0;
protected static final int TYPE = NON_PORTABLE;
protected final static String configDefaultTextKey = "";
protected final static String configDefaultTextSalt = "";
protected final static String configDefaultTextAlgorithm = "AES-128";
protected final static String configDefaultFileEnDecryptKey = "";
protected final static String configDefaultFileEnDecryptSalt = "";
protected final static String configDefaultFileEnDecryptAlgorithm = "AES-128";
protected final static int configDefaultFileDeleteIterations = 5;
protected final static String configDefaultFileOutputPath = "";
protected final static boolean configDefaultRemoveFileFromFileBox = false;
protected final static boolean configDefaultLimitNumberOfThreads = true;
private final static byte[] buffer = new byte[64];
private static Stage mainStage;
private double rootWindowX, rootWindowY;
protected static File config;
protected static boolean isConfig;
/**
* <p>Start the GUI</p>
*
* @param primaryStage of the GUI
* @throws IOException if issues with loading 'mainGUI.fxml'
*
* @since 1.0.0
*/
@Override
public void start(Stage primaryStage) throws IOException {
Thread.setDefaultUncaughtExceptionHandler(Main::exceptionAlert);
mainStage = primaryStage;
Parent root = FXMLLoader.load(getClass().getResource("resources/mainGUI.fxml"));
primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.setResizable(false);
primaryStage.setTitle("cryptoGX");
primaryStage.getIcons().add(new Image(getClass().getResource("resources/cryptoGX.png").toExternalForm()));
Scene scene = new Scene(root);
//Scene scene = new Scene(root, 900, 470);
scene.setOnMouseDragged(event -> {
primaryStage.setX(event.getScreenX() + rootWindowX);
primaryStage.setY(event.getScreenY() + rootWindowY);
});
scene.setOnMousePressed(event -> {
rootWindowX = scene.getX() - event.getSceneX();
rootWindowY = scene.getY() - event.getSceneY();
});
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* <p>Enter method for the application.
* Can also be used to en- / decrypt text and files or secure delete files without starting GUI</p>
*
* @param args from the command line
* @return
* @throws BadPaddingException
* @throws NoSuchAlgorithmException if wrong algorithm is given (command line)
* @throws IllegalBlockSizeException if wrong size for key is given (command line)
* @throws NoSuchPaddingException
* @throws InvalidKeyException if invalid key is given (command line)
* @throws InvalidKeySpecException
* @throws IOException if files cannot be en- / decrypted or deleted correctly (command line)
* @throws InvalidAlgorithmParameterException if wrong algorithm parameters are given (command line)
*
* @since 1.0.0
*/
public static void main(String[] args) throws BadPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException, InvalidKeySpecException, IOException, InvalidAlgorithmParameterException {
if (Main.TYPE == Main.PORTABLE) {
String system = System.getProperty("os.name").toLowerCase();
if (system.startsWith("windows")) {
config = new File("C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\cryptoGX\\cryptoGX.config");
File directory = new File("C:\\Users\\" + System.getProperty("user.name") + "\\AppData\\Roaming\\cryptoGX");
if (!directory.isDirectory()) {
directory.mkdir();
}
} else if (system.startsWith("linux")) {
config = new File(System.getProperty("user.home") + "/.cryptoGX/cryptoGX.config");
File directory = new File(System.getProperty("user.home") + "/.cryptoGX/");
if (!directory.isDirectory()) {
directory.mkdir();
}
} else {
config = new File("cryptoGX.config");
}
} else {
config = new File("cryptoGX.config");
}
isConfig = config.isFile();
if (args.length == 0) {
launch(args);
} else {
args[0] = args[0].replace("-", "");
if (args[0].toLowerCase().equals("help") || args[0].toUpperCase().equals("H")) {
System.out.println("Usage AES: \n\n" +
" Text en- / decryption\n" +
" encrypt: <cryptoGX jar file> AES <key> <salt> encrypt <string>\n" +
" decrypt: <cryptoGX jar file> AES <key> <salt> decrypt <encrypted string>\n\n" +
" File en- / decryption\n" +
" encrypt: <cryptoGX jar file> AES <key> <salt> encrypt <path of file to encrypt> <encrypted file dest>\n" +
" decrypt: <cryptoGX jar file> AES <key> <salt> decrypt <encrypted file path> <decrypted file dest>\n\n" +
"File secure delete: <cryptoGX jar file> delete <iterations> <path of file to delete>"); //for <iterations> the argument 'default' can be used, which is 5
} else if (args[0].toLowerCase().equals("delete")) {
if (args.length > 3) {
System.err.println("To many arguments were given, expected 3");
} else if (args.length < 3) {
System.err.println("To few arguments were given, expected 3");
}
try {
if (args[1].equals("default")) {
args[1] = "5";
}
File deleteFile = new File(args[2]);
if (deleteFile.isFile()) {
SecureDelete.deleteFile(deleteFile, Integer.parseInt(args[1]), buffer);
} else if (deleteFile.isDirectory()) {
SecureDelete.deleteDirectory(args[2], Integer.parseInt(args[1]), buffer);
} else {
System.err.println("Couldn't find file " + args[4]);
System.exit(1);
}
} catch (NumberFormatException e) {
System.err.println(args[1] + " must be a number\n Error: " + e.getMessage());
}
} else if (args[0].toLowerCase().equals("aes")) {
if (args.length < 5) {
System.err.println("To few arguments were given");
System.exit(1);
} else if (args.length > 6) {
System.err.println("To many arguments were given");
System.exit(1);
}
EnDecrypt.AES aes;
if (args[2].isEmpty()) {
aes = new EnDecrypt.AES(args[1], new byte[16]);
} else {
aes = new EnDecrypt.AES(args[1], args[2].getBytes(StandardCharsets.UTF_8));
}
String type = args[3].toLowerCase();
if (args.length == 5) {
if (type.equals("encrypt")) {
System.out.println(Base64.getEncoder().encodeToString(aes.encrypt(args[4].getBytes(StandardCharsets.UTF_8))));
} else if (type.equals("decrypt")) {
System.out.println(aes.decrypt(args[4]));
} else {
System.err.println("Couldn't resolve argument " + args[3] + ", expected 'encrypt' or 'decrypt'");
System.exit(1);
}
} else {
if (type.equals("encrypt")) {
File inputFile = new File(args[4]);
if (inputFile.isFile()) {
aes.encryptFile(new FileInputStream(inputFile), new FileOutputStream(args[5]), new byte[64]);
} else if (inputFile.isDirectory()) {
aes.encryptDirectory(args[4], args[5], ".cryptoGX", new byte[64]);
} else {
System.err.println("Couldn't find file " + args[4]);
System.exit(1);
}
} else if (type.equals("decrypt")) {
File inputFile = new File(args[4]);
if (inputFile.isFile()) {
aes.decryptFile(new FileInputStream(inputFile), new FileOutputStream(args[5]), new byte[64]);
} else if (inputFile.isDirectory()) {
aes.decryptDirectory(args[4], args[5], "@.cryptoGX@", new byte[64]);
} else {
System.err.println("Couldn't find file " + args[4]);
System.exit(1);
}
} else {
System.err.println("Couldn't resolve argument " + args[3] + ", expected 'encrypt' or 'decrypt'");
System.exit(1);
}
}
System.exit(0);
}
}
}
/**
* <p>"Catch" all uncatched exceptions and opens an alert window</p>
*
* @param thread which called this method
* @param throwable of the thread which called the method
*
* @since 1.3.0
*/
private static void exceptionAlert(Thread thread, Throwable throwable) {
throwable.printStackTrace();
AtomicReference<Double> exceptionAlertX = new AtomicReference<>(Screen.getPrimary().getBounds().getMaxX() / 2);
AtomicReference<Double> exceptionAlertY = new AtomicReference<>(Screen.getPrimary().getBounds().getMaxY() / 2);
Alert enDecryptError = new Alert(Alert.AlertType.ERROR, "Error: " + throwable, ButtonType.OK);
enDecryptError.initStyle(StageStyle.UNDECORATED);
enDecryptError.setTitle("Error");
enDecryptError.setResizable(true);
((Stage) enDecryptError.getDialogPane().getScene().getWindow()).getIcons().add(new Image(Main.class.getResource("resources/cryptoGX.png").toExternalForm()));
enDecryptError.getDialogPane().setContent(new Label("Error: " + throwable));
Scene window = enDecryptError.getDialogPane().getScene();
window.setOnMouseDragged(dragEvent -> {
enDecryptError.setX(dragEvent.getScreenX() + exceptionAlertX.get());
enDecryptError.setY(dragEvent.getScreenY() + exceptionAlertY.get());
});
window.setOnMousePressed(pressEvent -> {
exceptionAlertX.set(window.getX() - pressEvent.getSceneX());
exceptionAlertY.set(window.getY() - pressEvent.getSceneY());
});
enDecryptError.show();
}
/**
* <p>Shows an error alert window</p>
*
* @param message which will the alert show
* @param error which will show after the message
*/
protected static void errorAlert(String message, String error) {
AtomicReference<Double> alertX = new AtomicReference<>(Screen.getPrimary().getBounds().getMaxX() / 2);
AtomicReference<Double> alertY = new AtomicReference<>(Screen.getPrimary().getBounds().getMaxY() / 2);
Alert enDecryptError = new Alert(Alert.AlertType.ERROR, message +
"\nError: " + error, ButtonType.OK);
enDecryptError.initStyle(StageStyle.UNDECORATED);
enDecryptError.setTitle("Error");
enDecryptError.setResizable(true);
((Stage) enDecryptError.getDialogPane().getScene().getWindow()).getIcons().add(new Image(Main.class.getResource("resources/cryptoGX.png").toExternalForm()));
enDecryptError.getDialogPane().setContent(new Label(message));
Scene window = enDecryptError.getDialogPane().getScene();
window.setOnMouseDragged(dragEvent -> {
enDecryptError.setX(dragEvent.getScreenX() + alertX.get());
enDecryptError.setY(dragEvent.getScreenY() + alertY.get());
});
window.setOnMousePressed(pressEvent -> {
alertX.set(window.getX() - pressEvent.getSceneX());
alertY.set(window.getY() - pressEvent.getSceneY());
});
enDecryptError.show();
}
/**
* <p>Shows an warning alert window</p>
*
* @param message that the alert window will show
*
* @since 1.4.0
*/
protected static void warningAlert(String message) {
AtomicReference<Double> alertX = new AtomicReference<>(Screen.getPrimary().getBounds().getMaxX() / 2);
AtomicReference<Double> alertY = new AtomicReference<>(Screen.getPrimary().getBounds().getMaxY() / 2);
Alert enDecryptError = new Alert(Alert.AlertType.WARNING, message, ButtonType.OK);
enDecryptError.initStyle(StageStyle.UNDECORATED);
enDecryptError.setTitle("Error");
((Stage) enDecryptError.getDialogPane().getScene().getWindow()).getIcons().add(new Image(Main.class.getResource("resources/cryptoGX.png").toExternalForm()));
enDecryptError.getDialogPane().setContent(new Label(message));
Scene window = enDecryptError.getDialogPane().getScene();
window.setOnMouseDragged(dragEvent -> {
enDecryptError.setX(dragEvent.getScreenX() + alertX.get());
enDecryptError.setY(dragEvent.getScreenY() + alertY.get());
});
window.setOnMousePressed(pressEvent -> {
alertX.set(window.getX() - pressEvent.getSceneX());
alertY.set(window.getY() - pressEvent.getSceneY());
});
enDecryptError.show();
}
}

View File

@ -0,0 +1,90 @@
package org.bytedream.cryptogx;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.TreeSet;
/**
* <p>Class for secure delete files<p/>
*
* @since 1.2.0
*/
public class SecureDelete {
public static void deleteDirectory(String directory, int iterations, byte[] buffer) throws IOException {
TreeSet<File> directories = new TreeSet<>();
Files.walk(Paths.get(directory)).map(Path::toFile).forEach(directoryFile -> {
if (directoryFile.isDirectory()) {
directories.add(directoryFile);
} else {
try {
SecureDelete.deleteFile(directoryFile, iterations, buffer);
} catch (IOException e) {
e.printStackTrace();
}
while (directoryFile.exists()) {
if (directoryFile.delete()) {
break;
}
}
}
});
File deleteDirectory = directories.last();
while (deleteDirectory != null) {
deleteDirectory.delete();
while (deleteDirectory.delete()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
deleteDirectory = directories.lower(deleteDirectory);
}
}
/**
* <p>Overwrites the file {@param iterations} times line by line with random bytes (minimal size {@param minFileSize}; maximal size {@param maxFileSize}) and delete it</p>
*
* @param file that should be deleted
* @param iterations how many times the file should be overwritten before it gets deleted
* @return if the file could be deleted
* @throws IOException
*
* @since 1.12.0
*/
public static void deleteFile(File file, int iterations, byte[] buffer) throws IOException {
SecureRandom secureRandom = new SecureRandom();
RandomAccessFile raf = new RandomAccessFile(file, "rws");
for (int i=0; i<iterations; i++) {
long length = file.length();
raf.seek(0);
raf.getFilePointer();
int pos = 0;
while (pos < length) {
secureRandom.nextBytes(buffer);
raf.write(buffer);
pos += buffer.length;
}
}
raf.close();
while (file.delete()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,739 @@
package org.bytedream.cryptoGX;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.stage.*;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.*;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import static org.bytedream.cryptogx.Main.*;
/**
* <p>Class for the user configuration / settings</p>
*
* @since 1.12.0
*/
public class Settings {
private static double addSettingsGUIX, addSettingsGUIY;
private static final HashSet<String> protectedSettingsNames = new HashSet<>(Arrays.asList("cryptoGX", "settings"));
/**
* <p>Shows a GUI where the user can save settings, which can load later</p>
*
* @param rootWindow from which this GUI will get called
* @param userSetting
* @throws IOException
*
* @since 1.11.0
*/
public static void addSettingGUI(Window rootWindow, Map<String, String> userSetting) throws IOException {
Map<String, String> newSettingItems = new HashMap<>();
Stage rootStage = new Stage();
rootStage.initOwner(rootWindow);
Parent addSettingsRoot = FXMLLoader.load(Settings.class.getResource("resources/addSettingsGUI.fxml"));
rootStage.initStyle(StageStyle.UNDECORATED);
rootStage.initModality(Modality.WINDOW_MODAL);
rootStage.setResizable(false);
rootStage.setTitle("cryptoGX");
Scene scene = new Scene(addSettingsRoot, 320, 605);
rootStage.setScene(scene);
scene.setOnMouseDragged(event -> {
rootStage.setX(event.getScreenX() + addSettingsGUIX);
rootStage.setY(event.getScreenY() + addSettingsGUIY);
});
scene.setOnMousePressed(event -> {
addSettingsGUIX = scene.getX() - event.getSceneX();
addSettingsGUIY = scene.getY() - event.getSceneY();
});
Thread thread = new Thread(() -> {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
Platform.runLater(() -> {
MenuBar menuBar = (MenuBar) addSettingsRoot.lookup("#menuBar");
menuBar.setOnMouseDragged(event -> {
rootStage.setX(event.getScreenX() + addSettingsGUIX);
rootStage.setY(event.getScreenY() + addSettingsGUIY);
});
menuBar.setOnMousePressed(event -> {
addSettingsGUIX = menuBar.getLayoutX() - event.getSceneX();
addSettingsGUIY = menuBar.getLayoutY() - event.getSceneY();
});
ImageView closeButton = (ImageView) addSettingsRoot.lookup("#closeButton");
closeButton.setOnMouseClicked(event -> rootStage.close());
TextField settingsNameEntry = (TextField) addSettingsRoot.lookup("#settingsNameEntry");
TextField textKeyEntry = (TextField) addSettingsRoot.lookup("#textKeyEntry");
textKeyEntry.setText(userSetting.get("textKey"));
TextField textSaltEntry = (TextField) addSettingsRoot.lookup("#textSaltEntry");
textSaltEntry.setText(userSetting.get("textSalt"));
ComboBox textAlgorithmBox = (ComboBox) addSettingsRoot.lookup("#textAlgorithmComboBox");
textAlgorithmBox.setItems(FXCollections.observableArrayList(Utils.algorithms.keySet()));
textAlgorithmBox.setValue(userSetting.get("textAlgorithm"));
TextField fileEnDecryptKeyEntry = (TextField) addSettingsRoot.lookup("#fileEnDecryptKeyEntry");
fileEnDecryptKeyEntry.setText(userSetting.get("fileEnDecryptKey"));
TextField fileEnDecryptSaltEntry = (TextField) addSettingsRoot.lookup("#fileEnDecryptSaltEntry");
fileEnDecryptSaltEntry.setText(userSetting.get("fileEnDecryptSalt"));
ComboBox fileEnDecryptAlgorithmBox = (ComboBox) addSettingsRoot.lookup("#fileEnDecryptAlgorithmComboBox");
fileEnDecryptAlgorithmBox.setItems(FXCollections.observableArrayList(Utils.algorithms.keySet()));
fileEnDecryptAlgorithmBox.setValue(userSetting.get("fileEnDecryptAlgorithm"));
TextField fileDeleteIterationEntry = (TextField) addSettingsRoot.lookup("#fileDeleteIterationsEntry");
fileDeleteIterationEntry.setText(userSetting.get("fileDeleteIterations"));
fileDeleteIterationEntry.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("[0-9]*")) {
fileDeleteIterationEntry.setText(oldValue);
}
});
TextField fileOutputPathEntry = (TextField) addSettingsRoot.lookup("#fileOutputPathEntry");
fileOutputPathEntry.setText(userSetting.get("fileOutputPath"));
Button fileOutputPathButton = (Button) addSettingsRoot.lookup("#fileOutputPathButton");
fileOutputPathButton.setOnAction(event -> {
DirectoryChooser directoryChooser = new DirectoryChooser();
File directory = directoryChooser.showDialog(rootWindow.getScene().getWindow());
try {
fileOutputPathEntry.setText(directory.getAbsolutePath());
} catch (NullPointerException e) {
e.printStackTrace();
}
});
CheckBox removeFromFileBoxCheckBox = (CheckBox) addSettingsRoot.lookup("#removeFromFileBoxCheckBox");
removeFromFileBoxCheckBox.setSelected(Boolean.parseBoolean(userSetting.get("removeFromFileBox")));
CheckBox limitNumberOfThreadsCheckBox = (CheckBox) addSettingsRoot.lookup("#limitNumberOfThreadsCheckBox");
limitNumberOfThreadsCheckBox.setSelected(Boolean.parseBoolean(userSetting.get("limitNumberOfThreads")));
PasswordField hiddenPasswordEntry = (PasswordField) addSettingsRoot.lookup("#hiddenPasswordEntry");
TextField visiblePasswordEntry = (TextField) addSettingsRoot.lookup("#visiblePasswordEntry");
CheckBox showPassword = (CheckBox) addSettingsRoot.lookup("#showPassword");
showPassword.setOnAction(event -> {
if (showPassword.isSelected()) {
visiblePasswordEntry.setText(hiddenPasswordEntry.getText());
visiblePasswordEntry.setVisible(true);
hiddenPasswordEntry.setVisible(false);
} else {
hiddenPasswordEntry.setText(visiblePasswordEntry.getText());
hiddenPasswordEntry.setVisible(true);
visiblePasswordEntry.setVisible(false);
}
});
CheckBox encryptSettings = (CheckBox) addSettingsRoot.lookup("#encryptSettings");
encryptSettings.setOnAction(event -> {
if (encryptSettings.isSelected()) {
hiddenPasswordEntry.setDisable(false);
visiblePasswordEntry.setDisable(false);
showPassword.setDisable(false);
} else {
hiddenPasswordEntry.setDisable(true);
visiblePasswordEntry.setDisable(true);
showPassword.setDisable(true);
}
});
Button saveButton = (Button) addSettingsRoot.lookup("#saveButton");
saveButton.setOnAction(event -> {
if (settingsNameEntry.getText().trim().isEmpty()) {
warningAlert("Add a name for the setting");
} else if (protectedSettingsNames.contains(settingsNameEntry.getText())) {
warningAlert("Please choose another name for this setting");
} else if (settingsNameEntry.getText().trim().contains(" ")) {
warningAlert("Setting name must not contain free space");
} else if (encryptSettings.isSelected()) {
try {
EnDecrypt.AES encrypt;
if (!hiddenPasswordEntry.isDisabled() && !hiddenPasswordEntry.getText().trim().isEmpty()) {
encrypt = new EnDecrypt.AES(hiddenPasswordEntry.getText(), new byte[16]);
} else if (!visiblePasswordEntry.getText().trim().isEmpty()) {
encrypt = new EnDecrypt.AES(visiblePasswordEntry.getText(), new byte[16]);
} else {
throw new InvalidKeyException("The key must not be empty");
}
newSettingItems.put("encrypted", "true");
newSettingItems.put("textKey", encrypt.encrypt(textKeyEntry.getText()));
newSettingItems.put("textSalt", encrypt.encrypt(textSaltEntry.getText()));
newSettingItems.put("textAlgorithm", encrypt.encrypt(textAlgorithmBox.getSelectionModel().getSelectedItem().toString()));
newSettingItems.put("fileEnDecryptKey", encrypt.encrypt(fileEnDecryptKeyEntry.getText()));
newSettingItems.put("fileEnDecryptSalt", encrypt.encrypt(fileEnDecryptSaltEntry.getText()));
newSettingItems.put("fileEnDecryptAlgorithm", encrypt.encrypt(fileEnDecryptAlgorithmBox.getSelectionModel().getSelectedItem().toString()));
newSettingItems.put("fileDeleteIterations", encrypt.encrypt(fileDeleteIterationEntry.getText()));
newSettingItems.put("fileOutputPath", encrypt.encrypt(fileOutputPathEntry.getText()));
newSettingItems.put("removeFromFileBox", encrypt.encrypt(String.valueOf(removeFromFileBoxCheckBox.isSelected())));
newSettingItems.put("limitNumberOfThreads", encrypt.encrypt(String.valueOf(limitNumberOfThreadsCheckBox.isSelected())));
if (!config.isFile()) {
try {
if (!config.createNewFile()) {
warningAlert("Couldn't create config file");
} else {
addSetting(config, settingsNameEntry.getText().trim(), newSettingItems);
}
} catch (IOException e) {
e.printStackTrace();
errorAlert("Couldn't create config file", e.getMessage());
}
} else {
addSetting(config, settingsNameEntry.getText().trim(), newSettingItems);
}
rootStage.close();
} catch (InvalidKeyException e) {
warningAlert("The key must not be empty");
} catch (NoSuchPaddingException | NoSuchAlgorithmException | IllegalBlockSizeException | BadPaddingException | InvalidKeySpecException e) {
e.printStackTrace();
}
} else {
newSettingItems.put("textKey", textKeyEntry.getText());
newSettingItems.put("textSalt", textSaltEntry.getText());
newSettingItems.put("textAlgorithm", textAlgorithmBox.getSelectionModel().getSelectedItem().toString());
newSettingItems.put("fileEnDecryptKey", fileEnDecryptKeyEntry.getText());
newSettingItems.put("fileEnDecryptSalt", fileEnDecryptSaltEntry.getText());
newSettingItems.put("fileEnDecryptAlgorithm", fileEnDecryptAlgorithmBox.getSelectionModel().getSelectedItem().toString());
newSettingItems.put("fileDeleteIterations", fileDeleteIterationEntry.getText());
newSettingItems.put("fileOutputPath", fileOutputPathEntry.getText());
newSettingItems.put("removeFromFileBox", String.valueOf(removeFromFileBoxCheckBox.isSelected()));
newSettingItems.put("limitNumberOfThreads", String.valueOf(limitNumberOfThreadsCheckBox.isSelected()));
if (!config.isFile()) {
try {
if (!config.createNewFile()) {
warningAlert("Couldn't create config file");
} else {
addSetting(config, settingsNameEntry.getText().trim(), newSettingItems);
}
} catch (IOException e) {
e.printStackTrace();
errorAlert("Couldn't create config file", e.getMessage());
}
} else {
addSetting(config, settingsNameEntry.getText().trim(), newSettingItems);
}
rootStage.close();
}
});
});
});
thread.start();
rootStage.showAndWait();
}
/**
* <p>Shows a GUI where the user can export settings to a extra file</p>
*
* @param rootWindow from which this GUI will get called
* @throws IOException
*
* @since 1.11.0
*/
public static void exportSettingsGUI(Window rootWindow) throws IOException {
Stage rootStage = new Stage();
rootStage.initOwner(rootWindow);
Parent exportSettingsRoot = FXMLLoader.load(Settings.class.getResource("resources/exportSettingsGUI.fxml"));
rootStage.initStyle(StageStyle.UNDECORATED);
rootStage.initModality(Modality.WINDOW_MODAL);
rootStage.setResizable(false);
rootStage.setTitle("cryptoGX");
Scene scene = new Scene(exportSettingsRoot, 254, 253);
rootStage.setScene(scene);
scene.setOnMouseDragged(event -> {
rootStage.setX(event.getScreenX() + addSettingsGUIX);
rootStage.setY(event.getScreenY() + addSettingsGUIY);
});
scene.setOnMousePressed(event -> {
addSettingsGUIX = scene.getX() - event.getSceneX();
addSettingsGUIY = scene.getY() - event.getSceneY();
});
Thread thread = new Thread(() -> {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
MenuBar menuBar = (MenuBar) exportSettingsRoot.lookup("#menuBar");
menuBar.setOnMouseDragged(event -> {
rootStage.setX(event.getScreenX() + addSettingsGUIX);
rootStage.setY(event.getScreenY() + addSettingsGUIY);
});
menuBar.setOnMousePressed(event -> {
addSettingsGUIX = menuBar.getLayoutX() - event.getSceneX();
addSettingsGUIY = menuBar.getLayoutY() - event.getSceneY();
});
ImageView closeButton = (ImageView) exportSettingsRoot.lookup("#closeButton");
closeButton.setOnMouseClicked(event -> rootStage.close());
VBox settingsBox = (VBox) exportSettingsRoot.lookup("#settingsBox");
Platform.runLater(() -> readSettings(config).keySet().forEach(s -> {
CheckBox newCheckBox = new CheckBox();
newCheckBox.setText(s);
settingsBox.getChildren().add(newCheckBox);
}));
Button exportButton = (Button) exportSettingsRoot.lookup("#exportButton");
exportButton.setOnAction(event -> {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Export settings");
fileChooser.setInitialFileName("settings.config");
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Config files", "*.config"),
new FileChooser.ExtensionFilter("All files", "*.*"));
File file = fileChooser.showSaveDialog(exportSettingsRoot.getScene().getWindow());
if (file != null) {
TreeMap<String, Map<String, String>> writeInfos = new TreeMap<>();
TreeMap<String, Map<String, String>> settings = readSettings(config);
for (int i=0; i<settingsBox.getChildren().size(); i++) {
CheckBox checkBox = (CheckBox) settingsBox.getChildren().get(i);
if (checkBox.isSelected()) {
String checkBoxText = checkBox.getText();
writeInfos.put(checkBoxText, settings.get(checkBoxText));
}
}
if (!file.getAbsolutePath().contains(".")) {
file = new File(file.getAbsolutePath() + ".config");
}
writeSettings(file, writeInfos);
}
});
});
thread.start();
rootStage.showAndWait();
}
/**
* <p>Shows a GUI where the user can load saved settings</p>
*
* @param rootWindow from which this GUI will get called
* @return the settings that the user has chosen
* @throws IOException
*
* @since 1.11.0
*/
public static TreeMap<String, Map<String, String>> loadSettingsGUI(Window rootWindow) throws IOException {
Button[] outerLoadButton = new Button[1];
HashMap<String, String> setting = new HashMap<>();
TreeMap<String, Map<String, String>> settingItems = readSettings(config);
TreeMap<String, Map<String, String>> returnItems = new TreeMap<>();
Stage rootStage = new Stage();
rootStage.initOwner(rootWindow);
AnchorPane loadSettingsRoot = FXMLLoader.load(Settings.class.getResource("resources/loadSettingsGUI.fxml"));
rootStage.initStyle(StageStyle.UNDECORATED);
rootStage.initModality(Modality.WINDOW_MODAL);
rootStage.setResizable(false);
rootStage.setTitle("cryptoGX");
rootStage.getIcons().add(new Image(Settings.class.getResource("resources/cryptoGX.png").toExternalForm()));
Scene scene = new Scene(loadSettingsRoot, 242, 235);
scene.setOnMouseDragged(event -> {
rootStage.setX(event.getScreenX() + addSettingsGUIX);
rootStage.setY(event.getScreenY() + addSettingsGUIY);
});
scene.setOnMousePressed(event -> {
addSettingsGUIX = scene.getX() - event.getSceneX();
addSettingsGUIY = scene.getY() - event.getSceneY();
});
scene.setOnKeyReleased(event -> {
if (event.getCode() == KeyCode.ENTER) {
outerLoadButton[0].fire();
}
});
Thread thread = new Thread(() -> {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
Platform.runLater(() -> {
MenuBar menuBar = (MenuBar) loadSettingsRoot.lookup("#menuBar");
menuBar.setOnMouseDragged(event -> {
rootStage.setX(event.getScreenX() + addSettingsGUIX);
rootStage.setY(event.getScreenY() + addSettingsGUIY);
});
menuBar.setOnMousePressed(event -> {
addSettingsGUIX = menuBar.getLayoutX() - event.getSceneX();
addSettingsGUIY = menuBar.getLayoutY() - event.getSceneY();
});
ImageView closeButton = (ImageView) loadSettingsRoot.lookup("#closeButton");
if (settingItems.isEmpty()) {
rootStage.close();
}
closeButton.setOnMouseClicked(event -> {
setting.put("textKey", configDefaultTextKey);
setting.put("textSalt", configDefaultTextSalt);
setting.put("textAlgorithm", configDefaultTextAlgorithm);
setting.put("fileEnDecryptKey", configDefaultFileEnDecryptKey);
setting.put("fileEnDecryptSalt", configDefaultFileEnDecryptSalt);
setting.put("fileEnDecryptAlgorithm", configDefaultFileEnDecryptAlgorithm);
setting.put("fileDeleteIterations", String.valueOf(configDefaultFileDeleteIterations));
setting.put("fileOutputPath", configDefaultFileOutputPath);
setting.put("removeFromFileBox", String.valueOf(configDefaultRemoveFileFromFileBox));
setting.put("limitNumberOfThreads", String.valueOf(configDefaultLimitNumberOfThreads));
returnItems.put("default", setting);
rootStage.close();
});
PasswordField keyHideEntry = (PasswordField) loadSettingsRoot.lookup("#passwordEntryHide");
TextField keyShowEntry = (TextField) loadSettingsRoot.lookup("#passwordEntryShow");
CheckBox showPassword = (CheckBox) loadSettingsRoot.lookup("#showPassword");
showPassword.setOnAction(event -> {
if (showPassword.isSelected()) {
keyShowEntry.setText(keyHideEntry.getText());
keyShowEntry.setVisible(true);
keyHideEntry.setVisible(false);
} else {
keyHideEntry.setText(keyShowEntry.getText());
keyHideEntry.setVisible(true);
keyShowEntry.setVisible(false);
}
});
ComboBox settingsBox = (ComboBox) loadSettingsRoot.lookup("#settingsBox");
settingsBox.setItems(FXCollections.observableArrayList(settingItems.keySet()));
settingsBox.setValue(settingItems.firstKey());
if (!Boolean.parseBoolean(settingItems.firstEntry().getValue().get("encrypted").trim())) {
keyHideEntry.clear();
keyHideEntry.setDisable(true);
keyShowEntry.setDisable(true);
showPassword.setDisable(true);
}
settingsBox.setOnAction(event -> {
try {
if (!Boolean.parseBoolean(settingItems.get(settingsBox.getSelectionModel().getSelectedItem().toString()).get("encrypted").trim())) {
keyHideEntry.clear();
keyHideEntry.setDisable(true);
keyShowEntry.clear();
keyShowEntry.setDisable(true);
showPassword.setDisable(true);
} else {
keyHideEntry.clear();
keyHideEntry.setDisable(false);
keyShowEntry.clear();
keyShowEntry.setDisable(false);
showPassword.setDisable(false);
}
} catch (NullPointerException e) {
//get called when delete button is pressed
}
});
Button loadButton = (Button) loadSettingsRoot.lookup("#loadButton");
loadButton.setOnAction(event -> {
String settingName = settingsBox.getSelectionModel().getSelectedItem().toString();
Map<String, String> selectedSetting = settingItems.get(settingName);
if (keyHideEntry.isDisabled() && showPassword.isDisabled() && showPassword.isDisabled()) {
setting.put("textKey", selectedSetting.get("textKey"));
setting.put("textSalt", selectedSetting.get("textSalt"));
setting.put("textAlgorithm", selectedSetting.get("textAlgorithm"));
setting.put("fileEnDecryptKey", selectedSetting.get("fileEnDecryptKey"));
setting.put("fileEnDecryptSalt", selectedSetting.get("fileEnDecryptSalt"));
setting.put("fileEnDecryptAlgorithm", selectedSetting.get("fileEnDecryptAlgorithm"));
setting.put("fileDeleteIterations", selectedSetting.get("fileDeleteIterations"));
setting.put("fileOutputPath", selectedSetting.get("fileOutputPath"));
setting.put("removeFromFileBox", selectedSetting.get("removeFromFileBox"));
setting.put("limitNumberOfThreads", selectedSetting.get("limitNumberOfThreads"));
returnItems.put(settingsBox.getSelectionModel().getSelectedItem().toString(), setting);
rootStage.close();
} else {
EnDecrypt.AES decryptSetting;
if (keyHideEntry.isVisible()) {
decryptSetting = new EnDecrypt.AES(keyHideEntry.getText(), new byte[16]);
} else {
decryptSetting = new EnDecrypt.AES(keyShowEntry.getText(), new byte[16]);
}
try {
Map<String, String> selectedEncryptedSetting = settingItems.get(settingName);
setting.put("textKey", decryptSetting.decrypt(selectedEncryptedSetting.get("textKey")));
setting.put("textSalt", decryptSetting.decrypt(selectedEncryptedSetting.get("textSalt")));
setting.put("textAlgorithm", decryptSetting.decrypt(selectedEncryptedSetting.get("textAlgorithm")));
setting.put("fileEnDecryptKey", decryptSetting.decrypt(selectedEncryptedSetting.get("fileEnDecryptKey")));
setting.put("fileEnDecryptSalt", decryptSetting.decrypt(selectedEncryptedSetting.get("fileEnDecryptSalt")));
setting.put("fileEnDecryptAlgorithm", decryptSetting.decrypt(selectedEncryptedSetting.get("fileEnDecryptAlgorithm")));
setting.put("fileDeleteIterations", String.valueOf(Integer.parseInt(decryptSetting.decrypt(selectedEncryptedSetting.get("fileDeleteIterations")))));
setting.put("fileOutputPath", decryptSetting.decrypt(selectedEncryptedSetting.get("fileOutputPath")));
setting.put("removeFromFileBox", decryptSetting.decrypt(selectedEncryptedSetting.get("removeFromFileBox")));
setting.put("limitNumberOfThreads", decryptSetting.decrypt(selectedEncryptedSetting.get("limitNumberOfThreads")));
returnItems.put(settingsBox.getSelectionModel().getSelectedItem().toString(), setting);
rootStage.close();
} catch (InvalidKeyException e) {
warningAlert("Wrong key is given");
} catch (NoSuchPaddingException | NoSuchAlgorithmException | IllegalBlockSizeException | BadPaddingException | InvalidKeySpecException e) {
e.printStackTrace();
warningAlert("Wrong key is given or the config wasn't\nsaved correctly");
}
}
});
outerLoadButton[0] = loadButton;
Button deleteButton = (Button) loadSettingsRoot.lookup("#deleteButton");
deleteButton.setOnAction(event -> {
AtomicReference<Double> deleteQuestionX = new AtomicReference<>((double) 0);
AtomicReference<Double> deleteQuestionY = new AtomicReference<>((double) 0);
Alert deleteQuestion = new Alert(Alert.AlertType.CONFIRMATION, "Delete " + settingsBox.getSelectionModel().getSelectedItem().toString() + "?", ButtonType.OK, ButtonType.CANCEL);
deleteQuestion.initStyle(StageStyle.UNDECORATED);
deleteQuestion.setTitle("Confirmation");
((Stage) deleteQuestion.getDialogPane().getScene().getWindow()).getIcons().add(new Image(Settings.class.getResource("resources/cryptoGX.png").toExternalForm()));
Scene window = deleteQuestion.getDialogPane().getScene();
window.setOnMouseDragged(dragEvent -> {
deleteQuestion.setX(dragEvent.getScreenX() + deleteQuestionX.get());
deleteQuestion.setY(dragEvent.getScreenY() + deleteQuestionY.get());
});
window.setOnMousePressed(pressEvent -> {
deleteQuestionX.set(window.getX() - pressEvent.getSceneX());
deleteQuestionY.set(window.getY() - pressEvent.getSceneY());
});
Optional<ButtonType> result = deleteQuestion.showAndWait();
if (result.get() == ButtonType.OK) {
if (settingItems.size() - 1 <= 0) {
for (int i = 0; i < 100; i++) {
if (config.isFile()) {
try {
SecureDelete.deleteFile(config, 5, new byte[64]);
isConfig = false;
rootStage.close();
break;
} catch (IOException e) {
e.printStackTrace();
}
}
}
rootStage.close();
} else if (deleteSetting(config, settingsBox.getSelectionModel().getSelectedItem().toString())) {
settingItems.remove(settingsBox.getSelectionModel().getSelectedItem().toString());
settingsBox.setItems(FXCollections.observableArrayList(settingItems.keySet()));
settingsBox.setValue(settingItems.firstKey());
} else {
warningAlert("Couldn't delete setting '" + settingsBox.getSelectionModel().getSelectedItem().toString() + "'");
}
}
});
});
});
thread.start();
rootStage.setScene(scene);
rootStage.showAndWait();
return returnItems;
}
/**
* <p>Shows a GUI where the user can save the current settings</p>
*
* @param settingName name of the new setting
* @param newSetting is the new setting key value pair
*
* @since 1.12.0
*/
public static void addSetting(File file, String settingName, Map<String, String> newSetting) {
TreeMap<String, Map<String, String>> settings = readSettings(file);
settings.put(settingName, newSetting);
writeSettings(file, settings);
}
/**
* <p>Deletes a saved setting</p>
*
* @param settingName of the setting
* @return if the setting could be found
*
* @since 1.12.0
*/
public static boolean deleteSetting(File file, String settingName) {
StringBuilder newConfig = new StringBuilder();
boolean delete = false;
boolean found = false;
try {
BufferedReader configReader = new BufferedReader(new FileReader(file));
String line;
while ((line = configReader.readLine()) != null) {
line = line.trim();
if (line.startsWith("[") && line.endsWith("]")) {
if (line.replace("[", "").replace("]", "").split(" ")[0].equals(settingName)) {
delete = true;
found = true;
} else if (delete) {
delete = false;
newConfig.append(line).append("\n");
} else {
newConfig.append(line).append("\n");
}
} else if (!delete) {
newConfig.append(line).append("\n");
}
}
configReader.close();
BufferedWriter configFile = new BufferedWriter(new FileWriter(file));
configFile.write(newConfig.toString());
configFile.newLine();
configFile.close();
} catch (IOException e) {
e.printStackTrace();
}
return found;
}
/**
* <p>Reads all settings saved in a file</>
*
* @param file from which the settings should be read from
* @return the settings
*
* @since 1.12.0
*/
public static TreeMap<String, Map<String, String>> readSettings(File file) {
TreeMap<String, Map<String, String>> returnMap = new TreeMap<>();
String settingName = null;
Map<String, String> settingValues = new HashMap<>();
try {
BufferedReader configReader = new BufferedReader(new FileReader(file));
String line;
while ((line = configReader.readLine()) != null) {
if (line.isEmpty()) {
continue;
} else if (line.startsWith("[") && line.endsWith("]")) {
if (settingName != null) {
returnMap.put(settingName, settingValues);
settingValues = new HashMap<>();
}
String[] newSetting = line.replace("[", "").replace("]", "").split(" ");
settingName = newSetting[0].trim();
String[] encoded = newSetting[1].split("=");
settingValues.put("encrypted", encoded[1]);
} else {
String[] keyValue = line.split("=");
try {
settingValues.put(keyValue[0], keyValue[1]);
} catch (IndexOutOfBoundsException e) {
settingValues.put(keyValue[0], "");
}
}
}
if (settingName != null) {
returnMap.put(settingName, settingValues);
}
configReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
warningAlert("Couldn't find file '" + file.getAbsolutePath() + "'"); // this should never raise
} catch (IOException e) {
e.printStackTrace();
errorAlert("An IO Exception occurred", e.getMessage());
}
return returnMap;
}
/**
* <p>Writes settings (could be more than one) to a file</p>
*
* @param file where the settings should be written in
* @param settings of the user
*
* @since 1.12.0
*/
public static void writeSettings(File file, TreeMap<String, Map<String, String>> settings) {
try {
BufferedWriter configWriter = new BufferedWriter(new FileWriter(file));
for (Map.Entry<String, Map<String, String>> settingElement: settings.entrySet()) {
configWriter.write("[" + settingElement.getKey() + " encrypted=" + Boolean.parseBoolean(settingElement.getValue().get("encrypted")) + "]");
configWriter.newLine();
for (Map.Entry<String, String> entry : settingElement.getValue().entrySet()) {
String key = entry.getKey();
if (!key.equals("encrypted")) {
configWriter.write(entry.getKey() + "=" + entry.getValue());
configWriter.newLine();
}
}
}
configWriter.newLine();
configWriter.close();
} catch (IOException e) {
e.printStackTrace();
errorAlert("An error occurred while saving the settings", e.getMessage());
}
}
}

View File

@ -0,0 +1,51 @@
package org.bytedream.cryptogx;
import java.util.TreeMap;
/**
* <p>Support class<p/>
*
* @since 1.3.0
*/
public class Utils {
public static TreeMap<String, String> algorithms = allAlgorithms();
/**
* <p>Get all available algorithms</p>
*
* @return all available algorithms
*
* @since 1.12.0
*/
private static TreeMap<String, String> allAlgorithms() {
TreeMap<String, String> return_map = new TreeMap<>();
int[] aesKeySizes = {128, 192, 256};
for (int i: aesKeySizes) {
return_map.put("AES-" + i, "AES");
}
return return_map;
}
/**
* <p>Checks if any character in {@param characters} appears in {@param string}</p>
*
* @param characters that should be searched in {@param string}
* @param string that should be searched for the characters
* @return if any character in {@param characters} appears in {@param string}
*
* @since 1.3.0
*/
public static boolean hasAnyCharacter(CharSequence characters, String string) {
for (char c: characters.toString().toCharArray()) {
if (string.indexOf(c) != -1) {
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="rootWindow" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="605.0" prefWidth="320.0" style="-fx-border-color: black;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar fx:id="menuBar" prefHeight="25.0" prefWidth="320.0" style="-fx-border-color: black;" />
<ImageView fx:id="closeButton" fitHeight="25.0" fitWidth="25.0" layoutX="295.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@close.png" />
</image>
</ImageView>
<Text fx:id="saveSettingsText" layoutX="107.0" layoutY="46.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Save settings" textAlignment="CENTER" wrappingWidth="106.88330078125" />
<Text fx:id="nameOfSettingText" layoutX="49.0" layoutY="90.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Name of the new configuration" textAlignment="CENTER" wrappingWidth="221.84912109375" />
<TextField fx:id="settingsNameEntry" layoutX="27.0" layoutY="101.0" prefHeight="25.0" prefWidth="264.0" />
<Accordion fx:id="rootAccordion" layoutX="10.0" layoutY="150.0" prefHeight="280.0" prefWidth="300.0">
<panes>
<TitledPane fx:id="textEnDecryptRoot" animated="false" text="Text en - / decrypt">
<content>
<AnchorPane fx:id="textEnDecryptPane" minHeight="0.0" minWidth="0.0" prefWidth="200.0">
<children>
<Text fx:id="textKeyText" layoutX="10.0" layoutY="40.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Key" />
<TextField fx:id="textKeyEntry" layoutX="85.0" layoutY="23.0" prefHeight="25.0" prefWidth="175.0" />
<Text fx:id="textSaltText" layoutX="10.0" layoutY="90.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Salt" />
<TextField fx:id="textSaltEntry" layoutX="85.0" layoutY="73.0" prefHeight="25.0" prefWidth="175.0" />
<Text fx:id="textAlgorithmText" layoutX="10.0" layoutY="140.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Algorithm" />
<ComboBox fx:id="textAlgorithmComboBox" layoutX="85.0" layoutY="123.0" prefHeight="25.0" prefWidth="175.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="fileEnDecryptRoot" animated="false" text="File en- / decrypt">
<content>
<AnchorPane fx:id="fileEnDecryptPane" minHeight="0.0" minWidth="0.0" prefWidth="200.0">
<children>
<Text fx:id="fileEnDecryptKeyText" layoutX="10.0" layoutY="40.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Key" />
<TextField fx:id="fileEnDecryptKeyEntry" layoutX="85.0" layoutY="23.0" prefHeight="25.0" prefWidth="175.0" />
<Text fx:id="fileEnDecryptSaltText" layoutX="10.0" layoutY="90.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Salt" />
<TextField fx:id="fileEnDecryptSaltEntry" layoutX="85.0" layoutY="73.0" prefHeight="25.0" prefWidth="175.0" />
<Text fx:id="fileEnDecryptAlgorithmText" layoutX="10.0" layoutY="140.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Algorithm" />
<ComboBox fx:id="fileEnDecryptAlgorithmComboBox" layoutX="85.0" layoutY="123.0" prefHeight="25.0" prefWidth="175.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="fileDeleteRoot" animated="false" text="Secure delete files">
<content>
<AnchorPane fx:id="fileDeletePane" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Text fx:id="fileDeleteIterationsText" layoutX="14.0" layoutY="94.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Iterations" />
<TextField fx:id="fileDeleteIterationsEntry" layoutX="85.0" layoutY="77.0" prefHeight="25.0" prefWidth="175.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="settingsRoot" animated="false" text="Settings">
<content>
<AnchorPane fx:id="settingsPane" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Text fx:id="fileOutputPathText" layoutX="10.0" layoutY="20.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Default file output path" />
<TextField fx:id="fileOutputPathEntry" layoutX="10.0" layoutY="29.0" prefHeight="25.0" prefWidth="280.0" />
<Button fx:id="fileOutputPathButton" layoutX="71.0" layoutY="66.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="157.0" text="Change output path" textAlignment="CENTER" />
<CheckBox fx:id="removeFromFileBoxCheckBox" layoutX="10.0" layoutY="102.0" mnemonicParsing="false" prefHeight="38.0" prefWidth="287.0" text="Remove files from filebox after en- / decryption" wrapText="true" />
<CheckBox fx:id="limitNumberOfThreadsCheckBox" layoutX="10.0" layoutY="149.0" mnemonicParsing="false" text="Limit number of threads" />
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
<CheckBox fx:id="encryptSettings" layoutX="10.0" layoutY="447.0" mnemonicParsing="false" text="Encrypt settings" />
<Separator fx:id="separator1" layoutX="10.0" layoutY="474.0" prefWidth="300.0" />
<PasswordField fx:id="hiddenPasswordEntry" disable="true" layoutX="10.0" layoutY="490.0" prefHeight="25.0" prefWidth="300.0" promptText="Password" />
<TextField fx:id="visiblePasswordEntry" disable="true" layoutX="10.0" layoutY="490.0" prefHeight="25.0" prefWidth="300.0" promptText="Password" visible="false" />
<CheckBox fx:id="showPassword" disable="true" layoutX="10.0" layoutY="525.0" mnemonicParsing="false" text="Show password" />
<Separator fx:id="separator2" layoutX="10.0" layoutY="551.0" prefWidth="300.0" />
<Button fx:id="saveButton" layoutX="131.0" layoutY="564.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="56.0" text="Save" />
</children>
</AnchorPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="mainWindow" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="253.0" prefWidth="254.0" style="-fx-border-color: black;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar fx:id="menuBar" prefHeight="25.0" prefWidth="254.0" style="-fx-border-color: black;" />
<ImageView fx:id="closeButton" fitHeight="25.0" fitWidth="25.0" layoutX="228.0" layoutY="1.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@close.png" />
</image>
</ImageView>
<Text fx:id="exportSettingsText" layoutX="68.0" layoutY="49.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Export settings" textAlignment="CENTER" wrappingWidth="117.5283203125" />
<ScrollPane layoutX="7.0" layoutY="64.0" prefHeight="120.0" prefWidth="240.0">
<content>
<VBox fx:id="settingsBox" prefHeight="118.0" prefWidth="238.0" />
</content>
</ScrollPane>
<Button fx:id="exportButton" layoutX="86.0" layoutY="203.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="82.0" text="Export..." textAlignment="CENTER" />
</children>
</AnchorPane>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="rootWindow" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="235.0" prefWidth="242.0" style="-fx-border-color: black;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar fx:id="menuBar" prefHeight="25.0" prefWidth="242.0" style="-fx-border-color: black;" />
<ImageView fx:id="closeButton" fitHeight="25.0" fitWidth="25.0" layoutX="217.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@close.png" />
</image>
</ImageView>
<Text fx:id="loadSettingsText" layoutX="68.0" layoutY="47.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Load settings" textAlignment="CENTER" wrappingWidth="107.38818359375" />
<ComboBox fx:id="settingsBox" layoutX="24.0" layoutY="72.0" prefHeight="25.0" prefWidth="194.0" />
<PasswordField fx:id="passwordEntryHide" layoutX="16.0" layoutY="118.0" prefHeight="26.0" prefWidth="211.0" promptText="Password" />
<TextField fx:id="passwordEntryShow" layoutX="16.0" layoutY="118.0" prefHeight="26.0" prefWidth="211.0" visible="false" />
<CheckBox fx:id="showPassword" layoutX="14.0" layoutY="154.0" mnemonicParsing="false" text="Show password" />
<Separator fx:id="separator1" layoutX="16.0" layoutY="181.0" prefHeight="0.0" prefWidth="211.0" />
<Button fx:id="loadButton" layoutX="29.0" layoutY="193.0" mnemonicParsing="false" text="Load" />
<Button fx:id="deleteButton" layoutX="162.0" layoutY="193.0" mnemonicParsing="false" text="Delete" />
</children>
</AnchorPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="rootWindow" prefHeight="470.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.bytedream.cryptogx.Controller">
<children>
<MenuBar fx:id="menubar" prefHeight="25.0" prefWidth="900.0">
<menus>
<Menu fx:id="fileMenu" mnemonicParsing="false" text="File">
<items>
<MenuItem fx:id="fileMenuClose" mnemonicParsing="false" onAction="#closeApplication" text="Exit" />
</items>
</Menu>
<Menu fx:id="settingsMenu" mnemonicParsing="false" text="Settings">
<items>
<MenuItem fx:id="setDefaultOutputPath" mnemonicParsing="false" text="Set default file en- / decryption output path..." />
<RadioMenuItem fx:id="removeFileFromFileBox" mnemonicParsing="false" text="Remove files from file box after en- / decryption" />
<RadioMenuItem fx:id="limitNumberOfThreads" mnemonicParsing="false" selected="true" text="Limit number of threads" />
<SeparatorMenuItem fx:id="settingsSeparator1" mnemonicParsing="false" />
<MenuItem fx:id="saveSettings" mnemonicParsing="false" text="Save settings..." />
<MenuItem fx:id="loadSettings" disable="true" mnemonicParsing="false" text="Load settings..." />
<MenuItem fx:id="exportSettings" disable="true" mnemonicParsing="false" text="Export settings..." />
<MenuItem fx:id="importSettings" mnemonicParsing="false" text="Import settings..." />
</items></Menu>
<Menu fx:id="helpMenu" mnemonicParsing="false" text="Help"/>
</menus>
</MenuBar>
<ImageView fx:id="minimizeWindow" fitHeight="25.0" fitWidth="25.0" layoutX="850.0" onMouseClicked="#minimizeApplication" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@minimize.png" />
</image></ImageView>
<ImageView fx:id="closeWindow" fitHeight="25.0" fitWidth="25.0" layoutX="875.0" onMouseClicked="#closeApplication" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@close.png" />
</image></ImageView>
<Text fx:id="textText" layoutX="81.0" layoutY="49.0" strokeType="OUTSIDE" strokeWidth="0.0" text="En- / decrypt Text" textAlignment="CENTER" wrappingWidth="135.9" />
<TextField fx:id="textKeyEntry" layoutX="74.0" layoutY="64.0" onKeyTyped="#keyTypedTooltip" onMouseExited="#mouseExitEntryTooltip" onMouseMoved="#mouseOverEntryTooltip" prefHeight="25.0" prefWidth="155.0" promptText="Key" />
<TextArea fx:id="textDecryptedEntry" layoutX="7.0" layoutY="107.0" onKeyTyped="#keyTypedTooltip" prefHeight="105.0" prefWidth="286.0" promptText="Decrypted Text" />
<TextArea fx:id="textEncryptedEntry" layoutX="7.0" layoutY="222.0" onKeyTyped="#keyTypedTooltip" prefHeight="105.0" prefWidth="286.0" promptText="Encrypted Text" />
<Button fx:id="textEncryptButton" layoutX="29.0" layoutY="339.0" mnemonicParsing="false" onAction="#textEncryptButton" prefHeight="26.0" prefWidth="76.0" text="Encrypt" />
<ImageView fx:id="textLoadingImage" fitHeight="40.0" fitWidth="40.0" layoutX="131.0" layoutY="332.0" pickOnBounds="true" preserveRatio="true" />
<Button fx:id="textDecryptButton" layoutX="199.0" layoutY="340.0" mnemonicParsing="false" onAction="#textDecryptButton" prefHeight="26.0" prefWidth="76.0" text="Decrypt" />
<Separator fx:id="textSeparator1" layoutX="7.0" layoutY="379.0" prefHeight="8.0" prefWidth="103.0" />
<Text fx:id="textAdvanced" layoutX="106.0" layoutY="386.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Advanced" textAlignment="CENTER" wrappingWidth="85.9" />
<Separator fx:id="textSeparator2" layoutX="190.0" layoutY="379.0" prefHeight="8.0" prefWidth="103.0" />
<Text fx:id="textAlgorithm" layoutX="185.0" layoutY="409.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Algorithm" textAlignment="CENTER" wrappingWidth="77.6" />
<TextField fx:id="textSaltEntry" layoutX="14.0" layoutY="419.0" onKeyTyped="#keyTypedTooltip" onMouseExited="#mouseExitEntryTooltip" onMouseMoved="#mouseOverEntryTooltip" prefHeight="25.0" prefWidth="136.0" promptText="Salt" />
<ComboBox fx:id="textAlgorithmBox" layoutX="156.0" layoutY="419.0" prefHeight="25.0" prefWidth="136.0" />
<Separator fx:id="midSeparator1" layoutX="300.0" layoutY="35.0" orientation="VERTICAL" prefHeight="424.0" prefWidth="0.0" />
<Text fx:id="fileEnDecryptText" layoutX="384.0" layoutY="49.0" strokeType="OUTSIDE" strokeWidth="0.0" text="En- / decrypt Files" textAlignment="CENTER" wrappingWidth="135.9" />
<TextField fx:id="fileEnDecryptKeyEntry" layoutX="374.0" layoutY="64.0" onKeyTyped="#keyTypedTooltip" onMouseExited="#mouseExitEntryTooltip" onMouseMoved="#mouseOverEntryTooltip" prefHeight="25.0" prefWidth="155.0" promptText="Key" />
<Button fx:id="fileEnDecryptFilesButton" layoutX="316.0" layoutY="97.0" mnemonicParsing="false" onAction="#fileEnDecryptChooseFiles" prefHeight="26.0" prefWidth="120.0" text="Choose files..." />
<Text layoutX="445.0" layoutY="114.0" scaleX="1.7" scaleY="1.7" scaleZ="1.7" strokeType="OUTSIDE" strokeWidth="0.0" text="/" textAlignment="CENTER" wrappingWidth="12.111118853092194" />
<Button fx:id="fileEnDecryptDirectoriesButton" layoutX="467.0" layoutY="97.0" mnemonicParsing="false" onAction="#fileEnDecryptChooseDirectories" prefHeight="26.0" prefWidth="120.0" text="directories..." />
<ScrollPane fx:id="fileEnDecryptInputScroll" hbarPolicy="NEVER" layoutX="309.0" layoutY="130.0" onKeyPressed="#onFileEnDecryptPaste" prefHeight="107.0" prefWidth="286.0">
<content>
<VBox fx:id="fileEnDecryptInputFiles" onDragDropped="#onFileEnDecryptDragNDrop" onDragOver="#onFileEnDecryptDragOver" prefHeight="105.0" prefWidth="282.0" />
</content>
</ScrollPane>
<TextField fx:id="fileEncryptOutputFile" editable="false" layoutX="310.0" layoutY="245.0" onKeyTyped="#keyTypedTooltip" onMouseExited="#mouseExitEntryTooltip" onMouseMoved="#mouseOverEntryTooltip" prefHeight="26.0" prefWidth="286.0" promptText="Encrypted File" />
<TextField fx:id="fileDecryptOutputFile" editable="false" layoutX="310.0" layoutY="277.0" onKeyTyped="#keyTypedTooltip" onMouseExited="#mouseExitEntryTooltip" onMouseMoved="#mouseOverEntryTooltip" prefHeight="27.0" prefWidth="286.0" promptText="Decrypted File" />
<Button fx:id="fileEncrypt" layoutX="329.0" layoutY="314.0" mnemonicParsing="false" onAction="#fileEncryptButton" prefHeight="26.0" prefWidth="76.0" text="Encrypt" />
<ImageView fx:id="fileEnDecryptLoadingImage" fitHeight="40.0" fitWidth="40.0" layoutX="432.0" layoutY="306.0" pickOnBounds="true" preserveRatio="true" />
<Button fx:id="fileDecrypt" layoutX="499.0" layoutY="314.0" mnemonicParsing="false" onAction="#fileDecryptButton" prefHeight="26.0" prefWidth="76.0" text="Decrypt" />
<Button fx:id="fileEnDecryptStop" layoutX="417.0" layoutY="345.0" mnemonicParsing="false" onAction="#fileEnDecryptCancelButton" prefHeight="26.0" prefWidth="68.0" text="Cancel" />
<Separator fx:id="fileEnDecryptSeparator1" layoutX="309.0" layoutY="379.0" prefHeight="8.0" prefWidth="103.0" />
<Text fx:id="fileEnDecryptAdvanced" layoutX="409.0" layoutY="387.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Advanced" textAlignment="CENTER" wrappingWidth="85.9" />
<Separator fx:id="fileEnDecryptSeparator2" layoutX="489.0" layoutY="379.0" prefHeight="8.0" prefWidth="103.0" />
<Text fx:id="fileEnDecryptAlgorithm" layoutX="484.0" layoutY="409.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Algorithm" textAlignment="CENTER" wrappingWidth="77.6" />
<TextField fx:id="fileEnDecryptSaltEntry" layoutX="311.0" layoutY="419.0" onKeyTyped="#keyTypedTooltip" onMouseExited="#mouseExitEntryTooltip" onMouseMoved="#mouseOverEntryTooltip" prefHeight="25.0" prefWidth="136.0" promptText="Salt" />
<ComboBox fx:id="fileEnDecryptAlgorithmBox" layoutX="455.0" layoutY="419.0" prefHeight="25.0" prefWidth="136.0" />
<Separator fx:id="midSeparator2" layoutX="600.0" layoutY="35.0" orientation="VERTICAL" prefHeight="424.0" prefWidth="0.0" />
<Text fx:id="fileDeleteText" layoutX="684.0" layoutY="49.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Secure delete files" textAlignment="CENTER" wrappingWidth="135.9" />
<Button fx:id="fileDeleteChooseFilesButton" layoutX="616.0" layoutY="64.0" mnemonicParsing="false" onAction="#fileDeleteChooseFiles" prefHeight="26.0" prefWidth="120.0" text="Choose files..." />
<Text layoutX="744.0" layoutY="81.0" scaleX="1.7" scaleY="1.7" scaleZ="1.7" strokeType="OUTSIDE" strokeWidth="0.0" text="/" textAlignment="CENTER" wrappingWidth="12.111118853092194" />
<Button fx:id="fileDeleteChooseDirectoriesButton" layoutX="764.0" layoutY="64.0" mnemonicParsing="false" onAction="#fileDeleteChooseDirectories" prefHeight="26.0" prefWidth="120.0" text="directories..." />
<ScrollPane fx:id="fileDeleteInputScroll" hbarPolicy="NEVER" layoutX="608.0" layoutY="100.0" prefHeight="228.0" prefWidth="285.0">
<content>
<VBox fx:id="fileDeleteInputFiles" onDragDropped="#onFileDeleteDragNDrop" onDragOver="#onFileDeleteDragOver" prefHeight="226.0" prefWidth="283.0" />
</content>
</ScrollPane>
<Button fx:id="fileDeleteButton" layoutX="646.0" layoutY="339.0" mnemonicParsing="false" onAction="#fileDelete" prefWidth="68.0" text="Delete" />
<ImageView fx:id="fileDeleteLoadingImage" fitHeight="40.0" fitWidth="40.0" layoutX="729.0" layoutY="332.0" pickOnBounds="true" preserveRatio="true" />
<Button fx:id="fileDeleteStop" layoutX="796.0" layoutY="339.0" mnemonicParsing="false" onAction="#fileDeleteCancelButton" prefWidth="68.0" text="Cancel" />
<Separator fx:id="fileDeleteSeparator1" layoutX="610.0" layoutY="379.0" prefHeight="8.0" prefWidth="103.0" />
<Text fx:id="fileDeleteAdvanced" layoutX="709.0" layoutY="387.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Advanced" textAlignment="CENTER" wrappingWidth="85.9" />
<Separator fx:id="fileDeleteSeparator2" layoutX="791.0" layoutY="379.0" prefHeight="8.0" prefWidth="103.0" />
<TextField fx:id="fileDeleteIterationsEntry" layoutX="684.0" layoutY="419.0" onKeyTyped="#keyTypedTooltip" onMouseExited="#mouseExitEntryTooltip" onMouseMoved="#mouseOverEntryTooltip" prefHeight="25.0" prefWidth="136.0" promptText="Iterations" text="5" />
<Text fx:id="version" fill="#0000006a" layoutX="-6.0" layoutY="465.0" scaleX="0.7" scaleY="0.7" strokeType="OUTSIDE" strokeWidth="0.0" text="v1.12.0" wrappingWidth="57.999987464019796">
<rotationAxis>
<Point3D />
</rotationAxis></Text>
</children>
</AnchorPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB