Skip to main content

Lightweight byte-oriented encryption library.

Project description

🍋 Lemonade Cryptography

Lemonade Cryptography is a lightweight byte-oriented encryption library based on modular arithmetic and symmetric key transformations.

Lemonade transforms binary data into encrypted data by applying mathematical operations between data bytes and cryptographic key bytes.

The core concept is:

Each byte of the data is encrypted by subtracting it from a corresponding byte of a secret key.

The original data can be recovered by applying the reverse operation using the same key.


Installation

Install Lemonade Cryptography using pip:

pip install lemonade-cryptography

Quick Start

from lemonade import encrypt, decrypt

message = b"Hello. We are looking for highly intelligent individuals."

crypt, key = encrypt(message)

print("Encrypted:")
print(crypt)

print("\nKey:")
print(key)

original = decrypt(crypt, key)

print("\nDecrypted:")
print(original)

Output:

Encrypted:
<encrypted bytes>

Key:
<secret key bytes>

Decrypted:
b'Hello. We are looking for highly intelligent individuals.'

Features

  • Symmetric key encryption
  • Byte-oriented processing
  • UTF-8 compatible through byte conversion
  • Random cryptographic key generation
  • Custom key encryption
  • .lemon encrypted file format
  • .sourkey key file format
  • Lightweight Python API

API Reference

encrypt()

encrypt(data_bytes: bytes) -> tuple[bytes, bytes]

Encrypts binary data and generates a random key with the same length as the input data.

Arguments

Argument Type Description
data_bytes bytes Data to encrypt

Returns

A tuple containing:

(
    encrypted_data,
    encryption_key
)

Example:

crypt, key = encrypt(b"Hello")

encrypt_with_key()

encrypt_with_key(
    data_bytes: bytes,
    key_bytes: bytes
) -> bytes

Encrypts binary data using an existing key.

If the key is shorter than the data, the key bytes are repeated cyclically.

Example:

Data:
ABCDEFG

Key:
XYZ

Used key:
XYZXYZX

Arguments

Argument Type Description
data_bytes bytes Data to encrypt
key_bytes bytes Existing encryption key

Returns

Encrypted data:

bytes

decrypt()

decrypt(
    crypt_bytes: bytes,
    key_bytes: bytes
) -> bytes

Decrypts Lemonade encrypted data using its key.

Arguments

Argument Type Description
crypt_bytes bytes Encrypted data
key_bytes bytes Encryption key

Returns

The original data:

bytes

Example:

message = decrypt(crypt, key)

generate_key()

generate_key(length: int) -> bytes

Generates a cryptographically secure random key.

Arguments

Argument Type Description
length int Number of bytes

Returns

Generated key:

bytes

File Processing

Lemonade supports its own encrypted file formats.

.lemon

Contains encrypted data.

Structure:

LEMON_MAGIC
encrypted bytes

.sourkey

Contains encryption keys.

Structure:

SOURKEY_MAGIC
key bytes

A .sourkey file can be reused to encrypt multiple data sources.

Example:

encrypt_with_sourkey_to_file(
    data,
    "output_directory",
    "key.sourkey"
)

How It Works

Lemonade operates directly on byte values.

Example:

A = 65
B = 66
C = 67

The encryption operation is:

C = (M - K) mod 256

Where:

Symbol Meaning
C Encrypted byte
M Original data byte
K Key byte

The decryption operation reverses the transformation:

M = (C + K) mod 256

More technical details can be found in:

docs/algorithm.md

Security Notice

Lemonade Cryptography is an experimental encryption library created for educational purposes and lightweight applications.

It is not intended to replace modern cryptographic standards such as AES or ChaCha20 in security-critical systems.

Always protect your encryption keys. Without the correct key, encrypted data cannot be recovered.


License

Lemonade Cryptography is licensed under the MIT License.

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

lemonade_cryptography-1.1.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

lemonade_cryptography-1.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file lemonade_cryptography-1.1.0.tar.gz.

File metadata

  • Download URL: lemonade_cryptography-1.1.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for lemonade_cryptography-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4bde4db99b45beced9eaa760cce7cc30af90e1602e47e6e35d7369663b250ffe
MD5 4b8cecfd37e1ef995b4d14503058f065
BLAKE2b-256 0174ac673c27adc16888cb8887f9109c4aa2530c456da6bcef8130d6e3110949

See more details on using hashes here.

File details

Details for the file lemonade_cryptography-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lemonade_cryptography-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f697d068c94888951c5aefbe688b35339c378edad4c09be2877fe7c679e6032
MD5 18e0117b5ef05730b5bb64ab53be52fd
BLAKE2b-256 3604c8a2f35a40427bb7a10abfbe81690ec00702181efbf227d688680e2dc2a7

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