Conversation
…s launched from the console
oleksandr-jr
left a comment
There was a problem hiding this comment.
I can't run test. Please have a look and try to fix it.
|
Доброго дня! Я виправив проблему, закоментувавши два класи – Controller
та JavaFXApp. Після цього тести успішно пройшли.[image: image.png]
сб, 19 жовт. 2024 р. о 15:48 oleksandr-jr ***@***.***> пише:
… ***@***.**** requested changes on this pull request.
I can't run test. Please have a look and try to fix it.
—
Reply to this email directly, view it on GitHub
<#11 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6MOT4AHOMV4V4SBNAEFLJDZ4JILHAVCNFSM6AAAAABNZIQ7NGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGNZZGQYTMNZVGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
oleksandr-jr
left a comment
There was a problem hiding this comment.
Overall, looks good to me.
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. 🙂
| try { | ||
| Arguments arguments = ArgumentParser.parse(args); | ||
|
|
||
| String content = FileManager.read(arguments.getFilePath()); | ||
| String result; | ||
| String newFile; | ||
|
|
||
| EncryptionUtil encryptionUtil = new EncryptionUtil(); | ||
| if (arguments.isEncryptionMode()) { | ||
| result = encryptionUtil.encrypt(content, arguments.getKey()); | ||
| newFile = NewFileName.getNewFileName(arguments.getFilePath(), "[ENCRYPTED]"); | ||
| } else if (arguments.isDecryptionMode()) { | ||
| result = encryptionUtil.decrypt(content, arguments.getKey()); | ||
| newFile = NewFileName.getNewFileName(arguments.getFilePath(), "[DECRYPTED]"); | ||
| } else if (arguments.isBruteForce()) { | ||
| if (arguments.hasFrequencyAnalysisFile()) { | ||
| String referenceContent = FileManager.read(arguments.getFrequencyAnalysisFilePath()); | ||
| FrequencyAnalysis frequencyAnalysis = new FrequencyAnalysis(); | ||
| result = frequencyAnalysis.analysis(content, referenceContent); | ||
| int foundKey = frequencyAnalysis.getKey_bf(); | ||
| newFile = NewFileName.getNewFileName(arguments.getFilePath(), "[DECRYPTED_KEY_" + foundKey + "]"); | ||
| System.out.println("Key found using frequency analysis: " + foundKey); | ||
| } else { | ||
| // Стандартний brute force | ||
| int key = new BruteForce().brute_force(content); | ||
| result = encryptionUtil.decrypt(content, key); | ||
| newFile = NewFileName.getNewFileName(arguments.getFilePath(), "[DECRYPTED]"); | ||
| System.out.println("Key found using brute force: " + key); | ||
| } | ||
| }else { | ||
| throw new IllegalArgumentException("Invalid mode. Use '-e' for encryption, '-d' for decryption, or '-bf' for brute force."); | ||
| } | ||
|
|
||
| FileManager.write(newFile, result); | ||
| System.out.println("Operation completed successfully. Output file: " + newFile); | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| } |
There was a problem hiding this comment.
This looks a little too complex. It could be split into a couple of separate methods. See more.
| return key_bf; | ||
| } | ||
|
|
||
| public String analysis(String encryptedText, String referenceText) { |
There was a problem hiding this comment.
Very good approach, I like it.
This method also cad be simplified a bit to be more readable.
| int result = 0; | ||
| int maxPopular = 0; | ||
|
|
||
| LanguageDetector languageStrategy = new CreateLanguage().createLanguageStrategy(s); |
There was a problem hiding this comment.
Calling this method using whole text might be uneffective.
|
|
||
| private boolean isEnglish(String text) { | ||
| for (char c : text.toLowerCase().toCharArray()) { | ||
| if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) != -1) { |
There was a problem hiding this comment.
What if the text is in Ukrainian but contains some English words?
No description provided.