Open
Conversation
oleksandr-jr
requested changes
Oct 19, 2024
Contributor
There was a problem hiding this comment.
This project is pure simplicity and elegance in good meaning.
Some tests are still failing, but I believe you'll fix it.
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
+35
to
+61
| for (int i = 1; i <= 25; i++) { | ||
| ArrayList<Character> rotatedAlphabet = new ArrayList<>(originalAlphabet); | ||
| Collections.rotate(rotatedAlphabet, i); | ||
| char[] charArray = input.toCharArray(); | ||
|
|
||
| StringBuilder builder = new StringBuilder(); | ||
| for (char symbol : charArray) { | ||
| builder.append(processSymbol(symbol, rotatedAlphabet)); | ||
| } | ||
| String output = builder.toString(); | ||
|
|
||
| int count = 0; | ||
| String[] words = output.split("\\s+"); | ||
| for (String word : words) { | ||
| if (engWords.contains(word.toLowerCase())) { | ||
| count++; | ||
| } | ||
| } | ||
|
|
||
| if (count > maxCount) { | ||
| maxCount = count; | ||
| key = i; | ||
| bestOutput = output; | ||
| } | ||
| } | ||
| Cypher.key = key; | ||
| return bestOutput; |
Contributor
There was a problem hiding this comment.
This code looks a little too complex. It might be simplified and split into methods. See more here
Comment on lines
20
to
35
| try { | ||
| 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); | ||
| fileManager.write(pathManager.newFilePath(runOptions), encryptedContent); | ||
| } | ||
| if (runOptions.getCommand() == Command.DECRYPT) { | ||
| String content = fileManager.read(runOptions.getFilePath()); | ||
| String decryptedContent = cypher.decrypt(content, runOptions.getKey()); | ||
| fileManager.write(pathManager.newFilePath(runOptions), decryptedContent); | ||
| } | ||
| if (runOptions.getCommand() == Command.BRUTEFORCE) { | ||
| String content = fileManager.read(runOptions.getFilePath()); | ||
| String bruteForceContent = cypher.bruteForce(content); | ||
| fileManager.write(pathManager.newFilePath(runOptions), bruteForceContent); | ||
| } |
Contributor
There was a problem hiding this comment.
This code contains duplicates. See here how to fix it.
Comment on lines
+10
to
+15
| String label = switch (runOptions.getCommand()) { | ||
| case ENCRYPT -> " [ENCRYPTED]"; | ||
| case DECRYPT -> " [DECRYPTED]"; | ||
| case BRUTEFORCE -> " [BRUTEFORCE]"; | ||
| default -> null; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.