Skip to content

Conversation

@DevEvge
Copy link

@DevEvge DevEvge commented Sep 6, 2024

No description provided.

Copy link
Contributor

@oleksandr-jr oleksandr-jr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the implementation and see your effort here to make this project.

I hope you enjoyed the process and learned new things during this project.
Furthermore, I wish to see more of your projects in next modules. 🙂

Comment on lines 18 to +30
<dependencies>
<!-- JavaFX dependencies -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a UI interface is really cool.

Comment on lines 36 to 64
public static void main(String[] args) {
Cypher cypher = new Cypher();
FileManager fileManager = new FileManager();
ArgumentsParser argumentsParser = new ArgumentsParser();
RunOptions runOptions = argumentsParser.parse(args);

if (args.length == 0) {
launch();
}
try {
RunOptions runOptions = argumentsParser.parse(args);
String content = fileManager.read(runOptions.getFilePath());

if (runOptions.getCommand() == Command.ENCRYPT) {
String content = fileManager.read(runOptions.getFilePath());
String encryptedContent = cypher.encrypt(content, runOptions.getKey());
String fileName = runOptions.getFilePath().getFileName().toString();
String newFileName = fileName.substring(0, fileName.length() - 4) + " [ENCRYPTED].txt";

Path newFilePath = runOptions.getFilePath().resolveSibling(newFileName);
fileManager.write(newFilePath, encryptedContent);
Path newFilePath = changeFileName.newFileName(runOptions, "ENCRYPTED");
fileManager.write(newFilePath, cypher.encrypt(content, runOptions.getKey()));
} else if (runOptions.getCommand() == Command.DECRYPT) {

Path newFilePath = changeFileName.newFileName(runOptions, "DECRYPTED");
fileManager.write(newFilePath, cypher.decrypt(content, runOptions.getKey()));
} else if (runOptions.getCommand() == Command.BRUTEFORCE) {

BruteForceResult result = cypher.bruteforce(content);
Path newFilePath = changeFileName.newFileNameWithKey(runOptions, "BRUTEFORCED", result.getKey());
fileManager.write(newFilePath, result.getDecryptedContent());
}
} catch (FileNotFoundException e) {
System.out.println("File not found");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always a good idea to keep the logic out of the main method.

import java.nio.file.Path;
import java.util.ResourceBundle;

public class Controller implements Initializable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good job here

@@ -0,0 +1,22 @@
package ua.com.javarush.gnew.exeptions;

public class FileNotFoundException extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Own exception type. Cool 😎

Comment on lines +7 to +21
public static final ArrayList<Character> ALPHABET_ENG = new ArrayList<>(Arrays.asList(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'));

private final ArrayList<Character> alphabet;
public static final ArrayList<Character> ALPHABET_UA = new ArrayList<>(Arrays.asList(
'а', 'б', 'в', 'г', 'ґ', 'д', 'е', 'є', 'ж', 'з', 'и', 'і', 'ї', 'й', 'к', 'л', 'м',
'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ь', 'ю', 'я'));

public static final ArrayList<Character> ALPHABET_ENG_UPPER = new ArrayList<>(Arrays.asList(
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'));

public static final ArrayList<Character> ALPHABET_UA_UPPER = new ArrayList<>(Arrays.asList(
'А', 'Б', 'В', 'Г', 'Ґ', 'Д', 'Е', 'Є', 'Ж', 'З', 'И', 'І', 'Ї', 'Й', 'К', 'Л', 'М',
'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ь', 'Ю', 'Я'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could get rid of two lists for each language and process uppercase dynamically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS Styles... Bravo 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants