Skip to main content

A Block Metadata-Driven Order-Preserving Encryption (BMDOPE)

Project description

pybmdope

BMDOPE (Block Metadata-Driven Order-Preserving Encryption) is a custom encryption library designed to process data securely while preserving the order of encrypted blocks.

Overview

BMDOPE is designed for scenarios where maintaining the order of encrypted data is critical, such as database indexing or range queries on encrypted data. It achieves this by encrypting data in blocks and using metadata to preserve the order of the blocks during encryption and decryption.

Disclaimer: The order-preserving properties of BMDOPE are currently available for numeric sorting only. Lexicographical ordering is supported only for data with fixed size.

Algorithm

  1. Block-Based Encryption: Data is divided into fixed-size blocks, and each block is encrypted individually using a key.
  2. Metadata Handling: Metadata is generated during encryption to store information about the length of each encrypted block. This metadata is encrypted separately to ensure security.
  3. Order Preservation: The encryption algorithm ensures that the lexicographical order of the plaintext blocks is preserved in the encrypted blocks.
  4. Key Management: The encryption key is reshuffled after processing each block to enhance security.

Use Cases

  • Encrypted Databases: Perform range queries or sorting operations on encrypted data without decrypting it.
  • Secure Indexing: Maintain the order of encrypted data for efficient indexing and retrieval.
  • Data Transmission: Securely transmit ordered data while preserving its structure.

Installation

From PyPI

Install the package directly from PyPI:

pip install pybmdope

From Source

To install the package from the source, use:

pip install -e .

This will install the package in editable mode, allowing you to make changes to the source code and use them immediately.

Usage

Example

from pybmdope.bmdope import BMDOPE

# Initialize BMDOPE with generated key and IV
key = BMDOPE.generate_key()
bmdope = BMDOPE(key, iv)

# Data to encrypt
data = b"example data for encryption"

# Encrypt the data
encrypted_data = bmdope.encrypt(data)
print(f"Encrypted Data: {encrypted_data}")

# Decrypt the data
decrypted_data = bmdope.decrypt(encrypted_data)
print(f"Decrypted Data: {decrypted_data.decode('utf-8')}")

Testing

Unit tests are provided for all modules and integration. Run the tests using:

python -m unittest discover -s tests

TODO

  • Replace binary string representation (e.g., b'1010101') with bitarray for improved performance and flexibility.

License

This project 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

pybmdope-1.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

pybmdope-1.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybmdope-1.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pybmdope-1.1.0.tar.gz
Algorithm Hash digest
SHA256 32bba56e8743fc2a078ded6f6fa69a12e01efe3aa10277fc97a7b3965092ca6d
MD5 ec7158d178c106df884b31d5031a983a
BLAKE2b-256 6854c15c326a6c74334ef7e54aa92f824f6ac8fd0f461b8ee020a3eff77d197a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybmdope-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pybmdope-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe4428bc93eb8c62edcf04a70fe53236be4ea055523aa4a972ef60d1fe7bac1
MD5 f78b8b57d89b6991e6cd657c7cb49222
BLAKE2b-256 d54d4096b18adc23d89c093591a7ad43bbb77da2adfc2608f20a637a8dee52b5

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