Skip to content

Conversation

@lgt77
Copy link

@lgt77 lgt77 commented Sep 2, 2024

No description provided.

lgt77 added 13 commits September 1, 2024 23:56
# Conflicts:
#	src/main/java/ua/com/javarush/gnew/Main.java
#	src/main/java/ua/com/javarush/gnew/crypto/Decrypt.java
#	src/main/java/ua/com/javarush/gnew/crypto/Encrypt.java
#	src/main/java/ua/com/javarush/gnew/crypto/KeyManager.java
#	src/main/java/ua/com/javarush/gnew/crypto/SymbolsBelonging.java
#	src/main/java/ua/com/javarush/gnew/file/FileManager.java
added the MostFrequentChar method (also for brute force)
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.

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. 🙂

Comment on lines +5 to +18
public class SymbolsBelonging {
protected Character symbolsBelongingABC(char symbol, ArrayList<Character> rotateAlphabet) {
int index = ConstantsForCryptor.ALPHABET.getCharsArrayConstant().indexOf(Character.toUpperCase(symbol));
if(Character.isLowerCase(symbol)){
return Character.toLowerCase(rotateAlphabet.get(index));
}
return rotateAlphabet.get(index);
}

protected Character symbolsBelongingPUNCTUATION(char symbol, ArrayList<Character> rotatePunctuation){
int index = ConstantsForCryptor.PUNCTUATION.getCharsArrayConstant().indexOf(symbol);
return rotatePunctuation.get(index);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually we already have similar method.
Character. isAlphabetic()
For punctuation, you could use Pattern.matches("\\p{IsPunctuation}", str)

return sb.toString();
}

public char MostFrequentChar(){
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the approach

Comment on lines +21 to 32
if(runOptions.getCommand() == Command.ENCRYPT || runOptions.getCommand() == Command.DECRYPT){
int key = keyManager.getKey(runOptions);
cryptor = new Cryptor(content, key);
String cryptoContent = cryptor.cypher();
NewFileNamePath path = new NewFileNamePath();
fileManager.write(path.newPath(runOptions) , cryptoContent);
} else if (runOptions.getCommand() == Command.BRUTEFORCE) {
cryptor = new Cryptor(content, keyManager.keySelection(runOptions));
String cryptoContent = cryptor.cypher();
NewFileNamePath path = new NewFileNamePath();
fileManager.write(path.newPath(runOptions) , cryptoContent);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Contains duplicates. See here how to get rid of it.

@lgt77
Copy link
Author

lgt77 commented Oct 19, 2024 via email

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