Skip to content
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 16 commits into from
Jul 29, 2022
Merged

Update English checker #39

merged 16 commits into from
Jul 29, 2022

Conversation

bee-san
Copy link
Owner

@bee-san bee-san commented Jul 27, 2022

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:

  • Using Cargo-Nextest instead of the regular Cargo test, which runs
    tests faster

There are 2 bugs in the English checker:

 // 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:

 // 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 :)

bee and others added 4 commits July 27, 2022 08:45
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 :)
@bee-san bee-san requested a review from swanandx July 28, 2022 06:45
@flameprbot
Copy link

flameprbot bot commented Jul 29, 2022

Alt Text

@flameprbot
Copy link

flameprbot bot commented Jul 29, 2022

Alt Text

@bee-san bee-san merged commit 87d0f4f into main Jul 29, 2022
@delete-merged-branch delete-merged-branch bot deleted the bee-fix-english-checker branch July 29, 2022 08:55
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