Problem

One of the largest problems I saw in Ciphey was the fact that it ran infinitely.

People think it will always work, or that Ciphey isn't doing anything.

Solution

I'm going to build a timer that automatically stops decryptions after 60 seconds (this is changeable). This enables us to do 2 things:

  1. People will no longer think it runs forever.
  2. It can return all possible results that it has come across for library purposes.
    1. A common request of the API is that instead of returning the first thing it finds, it returns all possible decryptions it found over a time period.

How

In our lib.rs file it calls a function crack() which does everything.

We can have a thread and time how long this function takes to run. If it takes over 60 seconds, we should terminate it.

Visuals

While Ares is running, users may think that it's doing nothing. We should create a count-down timer which counts down from 60 seconds to let the user know we're working.

$ Ares --text "neadndbbarhadnjad"
53 seconds remaining.

Users may see Ares as doing nothing, so we should also record how many decryptions it got to.

We can then return something like:

$ Ares --text "neadndbbarhadnjad"
Failed to find anything after 60 seconds and 1,103,819 decodings.
It is unlikely I can decrypt this text, to run infinitely use `--infinite`.

To help you on your journey, here are all of the encryptions I support:
<link>
It is unlikely that your text is encrypted with one of these.

Implementation

We will need to create 2 threads:

  1. Counts to 60 seconds, timer