-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update English checker #39
Merged
Merged
Conversation
This file contains 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
This updates the English checker to work on multiple words. There are some notable changes in this PR: * Using `Cargo-Nextest` instead of the regular Cargo test, which runs tests faster There are 2 bugs in the English checker: ```rust // TODO: I think the below function iterates through each dictionary in turn. // Which means it'll try English.txt, then rockyou.txt etc // This is inefficient and makes it harder to compute what dictionary the word came from. // We should probably just use a single dictionary and assign the filenames to the values in the dictionary. // Like {"hello": "English.txt"} etc. // If we're using muiltiple dictionaries we may also have duplicated words which is inefficient. if storage::DICTIONARIES.iter().find(|(_, words)| words.contains(word)).is_some() { trace!("Found word {} in English", word); words_found += 1.0; } ``` And: ```rust // TODO: There is a bug here. We are comparing how many words found to how many characters there are in bytes. // This means the numbers don't exactly match up. There may be some cases where this will break. // We are also typecasting to f64 instead of usize, which costs CPU cycles. if words_found / input.len() as f64 > PLAINTEXT_DETECTION_PERCENTAGE { debug!("Found {} words in {}", words_found, input); debug!("Returning from English chekcer successfully with {}", input); plaintext_found = true; break; } ``` I will fix these in a future PR. This PR is designed to just let Skeletal work on a Caesar cipher :)
swanandx
approved these changes
Jul 28, 2022
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.
This updates the English checker to work on multiple words. Previously it only worked on 1 word.
There are some notable changes in this PR:
Cargo-Nextest
instead of the regular Cargo test, which runstests faster
There are 2 bugs in the English checker:
And:
I will fix these in a future PR. This PR is designed to just let
Skeletal work on a Caesar cipher :)