mirror of
https://github.com/Smaug123/ClassicalCiphers.jl
synced 2025-10-08 19:08:41 +00:00
Merge monoalphabetic cracking
This commit is contained in:
23
README.md
23
README.md
@@ -77,6 +77,29 @@ Notice that `encrypt_monoalphabetic` *does not* convert its input to uppercase
|
||||
when a Dict key is supplied.
|
||||
It simply makes all specified changes, and leaves the rest of the string unchanged.
|
||||
|
||||
Cracking a cipher:
|
||||
```julia
|
||||
crack_monoalphabetic(str, chatty=0, rounds=10)
|
||||
# outputs (key, decrypted_string)
|
||||
```
|
||||
|
||||
The various optional arguments to `crack_monoalphabetic` are:
|
||||
|
||||
* `starting_key=""`, which when specified (for example, as "ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
|
||||
starts the simulation at the given key. The default causes it to start with the most
|
||||
common characters being decrypted to the most common English characters.
|
||||
* `min_temp=0.0001`, which is the temperature at which we stop the simulation.
|
||||
* `temp_factor=0.97`, which is the factor by which the temperature decreases each step.
|
||||
* `chatty=0`, which can be set to 1 to print whenever the key is updated, or 2 to print
|
||||
whenever any new key is considered.
|
||||
* `rounds=1`, which sets the number of repetitions we perform. Each round starts with the
|
||||
best key we've found so far.
|
||||
* `acceptance_prob=((e, ep, t) -> ep>e ? 1 : exp(-(e-ep)/t))`, which is the probability
|
||||
with which we accept new key of fitness ep, given that the current key has fitness e,
|
||||
at temperature t.
|
||||
|
||||
The simulation is set up to start each round off at a successively lower temperature.
|
||||
|
||||
### Vigenère cipher
|
||||
|
||||
Encrypt the text "Hello, World!" with a Vigenère cipher of key "ab":
|
||||
|
Reference in New Issue
Block a user