Encrypt and break monoalphabetic and vigenère cipher using n-gram analysis.
mono.py [-h] (-e/--encrypt KEY | -d/--decrypt KEY) [-o/--out OUT] FILE
break_mono.py [-h] [-o/--out OUT] FILE
Encrypt a given plaintext with a chosen key.
$ python3 ./src/mono/mono.py -e ZEBRASCDFGHIJKLMNOPQTUVWXY ./examples/mono.plaintext -o ./examples/mono.ciphertext2
Decrypt a given ciphertext with the correct key.
$ python3 ./src/mono/mono.py -d ZEBRASCDFGHIJKLMNOPQTUVWXY ./examples/mono.ciphertext -o ./examples/mono.plaintext2
The breaker uses an evolutionary algorithm to iteratively improve the key. Multithreading is used by default. Amount of threads is adjustable. But depending on the used hardware, the breaking takes a while.
$ python3 ./src/mono/break_mono.py ./examples/mono.ciphertext -o ./examples/mono.key2
vig.py [-h] (-e/--encrypt KEY | -d/--decrypt KEY) [-o/--out OUT] FILE
break_vig.py [-h] -k/--keylen KEYLEN [-o/--out OUT] FILE
Encrypt a given plaintext with a chosen key.
$ python3 ./src/vig/vig.py -e hardkey ./examples/vig.plaintext -o ./examples/vig.ciphertext2
Decrypt a given ciphertext with the correct key.
$ python3 ./src/vig/vig.py -d hardkey ./examples/vig.ciphertext -o ./examples/mono.plaintext2
The breaker uses bigram analysis and needs the correct key length. The Kasiski examination and Friedman test can help to determine the key length.
$ python3 ./src/vig/break_vig.py -k 7 ./examples/vig.ciphertext -o ./examples/vig.key2
Special thanks to the Python genius @TrueKuehli