Skip to main content

Build Status Coverage License Black

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

Metadata

Release files for subbreaker 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for subbreaker 1.2.0
File Size Uploaded Provenance Actions
subbreaker-1.2.0.tar.gz 410.2 kB Without provenance Details for subbreaker-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for subbreaker 1.2.0
File Interpreter ABI Platform Actions
subbreaker-1.2.0-py3-none-any.whl Python 3 none any Details for subbreaker-1.2.0-py3-none-any.whl

Total release size: 821.8 kB

Release files / subbreaker-1.2.0.tar.gz

Download URL subbreaker-1.2.0.tar.gz
Size 410.2 kB
Tags Source
SHA-256 checksum
How to use checksums
70858cbba58790d7bf93a24dd91f7575215704ea2540f5c2e68fb55beec34b04
BLAKE2b-256 checksum
How to use checksums
5da0540c292b492b5ea4b04f5adc4749d81c3bfacc26af84f462dea7e9999056
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / subbreaker-1.2.0-py3-none-any.whl

Download URL subbreaker-1.2.0-py3-none-any.whl
Size 411.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12497a8bac86afd6e7395fc1efcb5f3135ee739423ac6da0bc8b2dde12bc2976
BLAKE2b-256 checksum
How to use checksums
9722523986d36018ba29768f055cb5b6c806caa77f50cad54c4f70e6fec1e39f
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for subbreaker 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page