Skip to main content

A package for reversible string obfuscation using Caesar cipher and deterministic shuffling.

Project description

MissButterfly

MissButterfly is a Python package for reversible string obfuscation, combining deterministic shuffling (using a salt) and Caesar cipher shifting. It is designed for lightweight, fast, and practical masking of sensitive data in logs, URLs, or configuration files.

Why the name "MissButterfly"? There is no technical reason for this name. I am a huge fan of animated series, and one of my favorites is "Star vs. the Forces of Evil." The main character, Star Butterfly, inspired the name of this project. She is one of my favorite characters in the series, along with Marco and Hekapoo. This project is named in her honor.

Note:
The core module butterfly_encoding is planned for future releases.
Currently, the main feature is the robust ButterflyMask class, which provides strong, layered obfuscation.


Why MissButterfly?

  • Layered Obfuscation: Combines deterministic, salt-based shuffling and Caesar cipher shifting for robust, reversible masking.
  • Difficult to Crack: For large strings, the combination of seeded shuffling and shifting makes brute-force reversal extremely difficult without the correct parameters.
  • Reversible: Unlike hashing, you can always recover the original string if you know the salt and parameters.
  • Lightweight & Dependency-Free: Pure Python, no external dependencies, Python 3.7+ compatible.

Features

  • ButterflyMask:
    • Reversible, layered obfuscation using both Caesar cipher and deterministic shuffling.
    • Configurable salt, shuffle mode (fixed or mixed), and Caesar shift.
    • Suitable for masking sensitive data in logs, URLs, or configs.
  • StringShuffler:
    • Deterministic, salt-based string shuffling and unshuffling.
  • CaesarCipher:
    • Classic Caesar cipher for simple character shifting.

ButterflyMask Shuffle Modes: fixed vs mixed

  • fixed:
    The encoding output of a given string will always be the same for the same salt and shift.

    Example: Encoding "Hello" with the same salt and shift will always produce the same encoded string.

  • mixed:
    The encoding output of a given string may be different each time you encode, even with the same salt and shift.
    However, every encoded string can always be decoded back to the original string.

    Example: Encoding "Hello" multiple times may produce different encoded strings, but all will decode to "Hello".


Installation

pip install MissButterfly

Or, from source:

git clone https://github.com/FireIndex/MissButterfly.git
cd MissButterfly
pip install .

Usage

ButterflyMask: Powerful, Reversible Masking

from MissButterfly import ButterflyMask

original = "SensitiveData123"

# Mixed shuffle mode (randomized per encode)
mask = ButterflyMask(salt="mysalt", shuffle_mode="mixed")
encoded = mask.encode(original) # Output may varry, ex. ne3tvai1eaSi2sDt_2129
print(f"Encoded: {encoded}")
decoded = mask.decode(encoded)
print(f"Decoded: {decoded}")  # Output: SensitiveData123

# Fixed shuffle mode (deterministic)
mask = ButterflyMask(salt="mysalt", shuffle_mode="fixed")
encoded = mask.encode(original) # Output: 3botzg1ko2kygYzJ
print(f"Encoded (fixed): {encoded}")
decoded = mask.decode(encoded)
print(f"Decoded (fixed): {decoded}")

Custom Caesar Cipher Shift

mask = ButterflyMask(salt="mysalt", shifte=7, shuffle_mode="mixed")
encoded = mask.encode("MySecret")
decoded = mask.decode(encoded)

CaesarCipher: Classic Shifting

from MissButterfly import CaesarCipher

cipher = CaesarCipher(shift=5)
encrypted = cipher.encrypt("HelloWorld")  # Output: MjqqtBtwqi
decrypted = cipher.decrypt(encrypted)     # Output: HelloWorld

StringShuffler: Deterministic Shuffling

from MissButterfly import StringShuffler

shuffler = StringShuffler(salt="mysalt")
shuffled = shuffler.shuffle("HelloWorld")
unshuffled = shuffler.unshuffle(shuffled)
print(unshuffled)  # Output: HelloWorld

API Reference

ButterflyMask

ButterflyMask(
    salt: str = "InitialSaltValue",
    shifte: int = 3,
    shuffle_mode: Literal['mixed', 'fixed'] = 'mixed'
)
  • salt: Salt value for deterministic shuffling.
  • shifte: Shift value for the outer Caesar cipher.
  • shuffle_mode: 'mixed' (random shuffle per encode) or 'fixed' (deterministic).

Methods:

  • encode(s: str) -> str: Encode a string.
  • decode(s: str) -> str: Decode a previously encoded string.
  • dict() -> dict: Get configuration as a dictionary.
  • copy(**kwargs) -> ButterflyMask: Copy with optional overrides.

CaesarCipher

CaesarCipher(shift: int)
  • encrypt(text: str) -> str
  • decrypt(text: str) -> str

StringShuffler

StringShuffler(salt: str)
  • shuffle(s: str) -> str
  • unshuffle(shuffled_str: str) -> str

Roadmap

  • butterfly_encoding:
    The upcoming core module for even more advanced, flexible, and secure encoding/decoding.

License

MIT License


Disclaimer:
MissButterfly is intended for lightweight obfuscation and masking, not for strong cryptographic security. Do not use for protecting highly sensitive or regulated data.

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

missbutterfly-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

missbutterfly-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file missbutterfly-0.1.1.tar.gz.

File metadata

  • Download URL: missbutterfly-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for missbutterfly-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2de1412db6d4bb39d244674b0d094435ad32489d8225eea25270b7d2e0b5d1e3
MD5 b7b053be073e7ee06bc98f9611864b3d
BLAKE2b-256 0a89242d7a90f60969173e836da783742645ed6c8c6cf671e1fc12b74abc590a

See more details on using hashes here.

File details

Details for the file missbutterfly-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: missbutterfly-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for missbutterfly-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1beecfd634d3d5baa1c9e13628230d899ab8c42112c2b6d291e66bec49665112
MD5 4b273b15a5243d127808495ce1898a8b
BLAKE2b-256 a5e0b55abee903d517f72903e24e9f5b68959a5eb228dc5ca0de7a1af0d1d83a

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