Skip to content

goncharov - 3 tasks (encrypt, decrypt, brute)#20

Open
GDGo wants to merge 1 commit intodemologin:mainfrom
GDGo:main
Open

goncharov - 3 tasks (encrypt, decrypt, brute)#20
GDGo wants to merge 1 commit intodemologin:mainfrom
GDGo:main

Conversation

@GDGo
Copy link

@GDGo GDGo commented Sep 1, 2025

No description provided.

Copy link
Owner

@demologin demologin left a comment

Choose a reason for hiding this comment

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

Написано консольное приложение с тремя методами кодирование и декодирования из четырёх возможных. Метод грубой силы написан не очень аккуратно и скорее всего не всегда работоспособен. По остальному коду есть небольшие замечания. Итоговая оценка б

@@ -0,0 +1,27 @@
package com.javarush.goncharov.constants;

public class ApplicationCompletionConstants {
Copy link
Owner

Choose a reason for hiding this comment

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

Слишком неудобное название. Проще было бы назвать Messages

@@ -0,0 +1,27 @@
package com.javarush.goncharov.constants;

public class ApplicationCompletionConstants {
Copy link
Owner

Choose a reason for hiding this comment

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

А ещё если бы это сделать в виде интерфейса то не пришлось бы писать public static final

@@ -0,0 +1,10 @@
package com.javarush.goncharov.constants;

public class CryptoAlphabet {
Copy link
Owner

Choose a reason for hiding this comment

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

И тут тоже

public class PathUtilsFunc {

public static String getInputFileEncode(String message){
System.out.println(message);
Copy link
Owner

Choose a reason for hiding this comment

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

в методах которые начинаются на Prefix get меньше всего ожидаешь увидеть вывод на консоль

public static int getInputMode(String message){
String input;
while (true){
System.out.println(message);
Copy link
Owner

Choose a reason for hiding this comment

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

и тут тоже самое

}

public static void close(){
System.exit(0);
Copy link
Owner

Choose a reason for hiding this comment

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

Такие способы завершения приложений настоящие ночной кошмар для тестировщика, поэтому так лучше программу никогда не останавливать. Это самое настоящий аварийный вариант и то место где стоит ноль обычно предназначено для указания аварийного кода выхода

Matcher matcher = PATTERN.matcher(textOutput);
if (matcher.find()) {
BruteForce.key = key;
BruteForce.find = true;
Copy link
Owner

Choose a reason for hiding this comment

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

Тут как-то очень ненадёжно сделано, этот метод вызывается отдельно для каждой строки, и получается что в некоторых строках он может установить флаг что решение найдены а в некоторых нет. Лучше было бы анализировать весь текст целиком

BufferedWriter writer = new BufferedWriter(new FileWriter(outputFileFile))){

while (reader.ready()){
writer.write(encodeText(reader.readLine(), key));
Copy link
Owner

Choose a reason for hiding this comment

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

кодирование и декодирования выполняется построчно а не посимвольно, это сильно поможет потенциальному взломщику определить границы строк

import static com.javarush.goncharov.view.Decode.decode;
import static com.javarush.goncharov.view.Encode.encode;

public class Menu {
Copy link
Owner

Choose a reason for hiding this comment

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

если в классе только статические методы то у него должен быть приватный конструктор пустой


public class EntryPoint {
public static void main(String[] args) {
run();
Copy link
Owner

Choose a reason for hiding this comment

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

в данном классе нет никакого смысла

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants