A tool to break substitution ciphers
Project description
Substitution Breaker
This project provides a Python implementation for breaking classical substitution ciphers.
More documentation of the project including a detailed description of the CLI and the python API is available as well.
Overview
A substitution cipher is a method of encryption by which the letters of the plaintext are systematically replaced by substitute letters. The receiver deciphers the text by performing an inverse substitution.
The correlation between the letters of the plaintext and the substitute letters is defined by the key.
Example:
Alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ Key: ZEBRASCDFGHIJKLMNOPQTUVWXY
The letter “A” from the plaintext maps to the cipher text “Z”, “B” to “E”, and so on. Thus the plaintext “flee at once. we are discovered!” is enciphered as “siaa zq lkba. va zoa rfpbluaoar!”
This package provides a CLI which supports the following operations:
encoding and decoding a text with a given key
breaking a substitution cipher text when the key is unknown (English language)
tools for adding support for other languages and/or other alphabets
All the features supported by the CLI are exposed through functions and classes by a Python package.
Installation
This package requires Python3.5 or higher. It can be installed using pip:
$ pip install subbreaker
Basic Usage
For a full documentation of the subbreaker command refer to the documentation here. There you will find also a detailed description how to use the package directly with Python. In the following only some basic examples for using the CLI are given.
The command subbreaker supports several subcommands. To display them type:
$ subbreaker --help
You can get a detailed help on every subcommand by subbreaker <subcommand> --help. And here comes subbreaker in action:
Encoding a clear text…
$ subbreaker encode --key ZEBRASCDFGHIJKLMNOPQTUVWXY --text "flee at once. we are discovered!"
siaa zq lkba. va zoa rfpbluaoar!
…and decoding it back:
$ subbreaker decode --key ZEBRASCDFGHIJKLMNOPQTUVWXY --text "siaa zq lkba. va zoa rfpbluaoar!"
flee at once. we are discovered!
Break a cipher without knowing the key:
$ subbreaker break --lang EN --text \
"Rbo rpktigo vcrb bwucja wj kloj hcjd, km sktpqo, cq rbwr loklgo
> vcgg cjqcqr kj skhcja wgkja wjd rpycja rk ltr rbcjaq cj cr.
> -- Roppy Lpwrsborr"
Key: wisdomabcznghjklfpqrtuvxye
Score: 103.68
Nbr keys tried: 37050
Keys per second: 61850
Execution time (seconds): 0.599
Plaintext:
The trouble with having an open mind, of course, is that people
will insist on coming along and trying to put things in it.
-- Terry Pratchett
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file subbreaker-1.2.0.tar.gz
.
File metadata
- Download URL: subbreaker-1.2.0.tar.gz
- Upload date:
- Size: 410.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70858cbba58790d7bf93a24dd91f7575215704ea2540f5c2e68fb55beec34b04 |
|
MD5 | 2d37816f52a6f85ada6bd09401059c3d |
|
BLAKE2b-256 | 5da0540c292b492b5ea4b04f5adc4749d81c3bfacc26af84f462dea7e9999056 |
File details
Details for the file subbreaker-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: subbreaker-1.2.0-py3-none-any.whl
- Upload date:
- Size: 411.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12497a8bac86afd6e7395fc1efcb5f3135ee739423ac6da0bc8b2dde12bc2976 |
|
MD5 | 4cd1c57cb6854d0a6fd75845fbdb30c4 |
|
BLAKE2b-256 | 9722523986d36018ba29768f055cb5b6c806caa77f50cad54c4f70e6fec1e39f |