Skip to main content

A Python library for for plaintext encryption using homophonic substitution and historical character frequencies.

Project description

ChronoFidelius

ChronoFidelius is a Python library for plaintext encryption using homophonic substitution and historical character frequencies. It provides configurable error injection, frequency-based key generation, and advanced encryption techniques inspired by historical cryptography.


Features

  • Homophonic Substitution Cipher: Encrypts plaintext with multiple cipher options for each character
  • Frequency-Based Key Generation: Supports even and uneven key generation using historical unigram frequencies
  • Error Injection: Introduces errors (additions, deletions, or doubles) into plaintext for obfuscation
  • Custom Configurations: Control error frequency, character spacing, and more

Installation

Install ChronoFidelius using pip:

pip install ChronoFidelius

Or, install directly from the source:

git clone https://github.com/mbruton0426/ChronoFidelius.git
cd ChronoFidelius
pip install .

Usage

When initializing ChronoFidelius, the only required variable is some text to encrypt, either as a str or list of str.

Initalization:

from chronofidelius import ChronoFidelius

# Initialize the ChronoFidelius object
cf = ChronoFidelius("Hello, World!")

Optional Parameters: initialization

  • set_seed (int, optional): A seed value for reproducibility of random operations. Default is None
  • include_errors (bool, optional): If True, introduces errors (e.g., additions, deletions, doubles) into the plaintext. Default is False
  • error_type (str, optional): Specifies the type of error to introduce. Must be set if include_errors is True. Default is None. Valid options are: - "additions": Adds random characters - "deletions": Removes characters - "doubles": Doubles characters - "all": Randomly selects between "additions", "deletions", or "doubles"
  • error_frequency (float, optional): Frequency of errors in the plaintext (0–1). For example, 0.05 introduces errors to 5% of the text. Default is 0.05
  • include_spacing (bool, optional): If True, retains spaces and line breaks during formatting. Default is False
  • max_length (int, optional): Maximum length of the formatted plaintext or chunks. Default is 200
  • set_punctuation (str, optional): Specifies the set of punctuation characters to remove. Default is string.punctuation

Encrypting Plaintexts

Plaintexts can be encrypted with:

cf.encrypt_homophonic()

This automatically encrypts plaintext(s) according to every possible option based on the default values. Plaintext(s), ciphertexts, and keys are then all available as a dictionary in:

cf.pt_ct_dict

Optional Parameters: encrypt_homophonic()

  • key_type (str): The type of encryption key ("even", "uneven", or "both"). Default is "even"
  • lang_code (str): Language code for character frequencies. Options: {'en', 'es', 'sv', 'de', 'fr', 'it'}
  • freq_year (str): Year range for character frequencies. Varies by language, available in chronofidelius/unigram_frequencies.py
  • set_frequencies (dict): Custom frequency mappings for uneven key generation
  • set_alphabet (str): Alphabet to use for key generation

Utilizing Custom Character Frequencies

All uneven-type encryptions require character frequencies. If the frequencies you would like to use are not available in chronofidelius/unigram_frequencies.py, you may input your own.

# Custom frequency dictionary
custom_frequencies = {"A": 0.1, "B": 0.2, "C": 0.3, "D": 0.4}

cf.encrypt_homophonic(set_frequencies=custom_frequencies)

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.


Citation

If you use this tool in your research, please cite:

@inproceedings{bruton2025statistics,
  title     = {From Statistics to Neural Networks: Enhancing Ciphertext-Plaintext Alignment in Historical Substitution Ciphers For Automatic Key Extraction},
  author    = {Bruton, Micaella and Megyesi, Be{\'a}ta},
  booktitle = {Proceedings of the International Conference on Historical Cryptology (HistoCrypt)},
  year      = {2025},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chronofidelius-1.1.1.tar.gz (87.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chronofidelius-1.1.1-py3-none-any.whl (89.9 kB view details)

Uploaded Python 3

File details

Details for the file chronofidelius-1.1.1.tar.gz.

File metadata

  • Download URL: chronofidelius-1.1.1.tar.gz
  • Upload date:
  • Size: 87.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for chronofidelius-1.1.1.tar.gz
Algorithm Hash digest
SHA256 cad58efbcb75fa6b3e31186b365a3494ff4cf04abb8df7bd1c0b912dbbac02f3
MD5 66ab8f1a2019c23876b030baae65e4dc
BLAKE2b-256 2f6a0c08eebb91f36360ac6cbfdf05d9b021471bd85d9c8e7bccdb2cb12da4c4

See more details on using hashes here.

File details

Details for the file chronofidelius-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: chronofidelius-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 89.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for chronofidelius-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a81f705b386380e43957ff91f97b670dde956f8ea8431191286c8895529b2895
MD5 051b8e39e5e2a1d6b5593cfec9fb60bd
BLAKE2b-256 c5a2ae479655621dc373cd01d827360f5db066e3970d1b5c57823683939efe00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page