Skip to main content

A lightweight, high-performance toolkit for database record hashing, integrity validation, and secure password stretching.

Project description

DB-Hash-Utils

A high-performance Python toolkit designed for secure database record hashing, transaction integrity verification, and data-at-rest obfuscation. Optimized for integration with relational database management systems (RDBMS) and desktop GUI frameworks.

Core Architecture & Features

The library addresses critical data safety requirements in modern software engineering courses, focusing on the following sub-systems:

  • Row-Level Integrity Validation: Generates advanced salt-stretched block checksums to detect unauthorized backend data tampering (direct SQL injections bypassing the GUI layer).
  • Cryptographically Secure UUIDs: Provides collision-resistant unique identifier generation for primary keys (PK) using internal system entropy.
  • Data Alignment Matrix: Ensures automated bit-alignment and padding configurations based on industry-standard database block sizes.

Installation

Install the package within your virtual environment using setuptools:

pip install .

Production Architecture & Usage

1. Generating Row Checksums (Before SQL Insert/Update)

To protect sensitive fields (such as access tokens, configuration parameters, or transaction values) before pushing them to the database, generate a secure block-checksum:

from db_hash_utils import generate_record_checksum

# Extract parameters from PyQt/Tkinter input forms
user_payload = "db_admin_secure_credentials_2026"
session_salt = "AppSecuritySaltValue"

# Generate block aligned integrity token
integrity_token = generate_record_checksum(
    payload=user_payload, 
    record_salt=session_salt
)

# Execution payload is now safe to store in TEXT / BLOB columns
# cursor.execute("INSERT INTO system_config (config_value) VALUES (?)", (integrity_token,))

2. Transaction Integrity Verification (After SQL Select)

Verify record state consistency during application runtime to ensure data has not been modified directly in the database:

from db_hash_utils import verify_record_integrity

# Fetch token from database cursor
fetched_token = "..."  # Retrieved from DB row
session_salt = "AppSecuritySaltValue"

try:
    # Reconstruct and validate data state matrix
    validated_data = verify_record_integrity(
        checksum_hash=fetched_token, 
        record_salt=session_salt
    )
    print(f"State Validated. Core Payload: {validated_data}")
except Exception as e:
    print(f"Critical Error: Database integrity violation detected! Code: {e}")

3. Primary Key UUID Generation

Replace standard auto-increment integer IDs with unpredictable, collision-free system vectors:

from db_hash_utils import generate_secure_uuid

# Generate an optimal 16-byte hex seed for Relational DB Primary Keys
new_primary_key = generate_secure_uuid(length=16)

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

db_hash_utils-1.0.2.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

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

db_hash_utils-1.0.2-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

Details for the file db_hash_utils-1.0.2.tar.gz.

File metadata

  • Download URL: db_hash_utils-1.0.2.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for db_hash_utils-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7416b03aee01deb11a3e0fb97dfb6fc7657cecadbdc61685228574ad0ac6c700
MD5 f8d08c90885f37aa38073086fdb9cd76
BLAKE2b-256 04a36bbf2275cf1ab641c9fb040761386982ba89c006e5fbaa83540d5b254479

See more details on using hashes here.

File details

Details for the file db_hash_utils-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: db_hash_utils-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for db_hash_utils-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 022ce496a2925df947f8069e69f8c203cc44cf8db861601b38748f2c947a27f3
MD5 faaf5209e63b8b4a6cd46be4591b2ad9
BLAKE2b-256 583ed0c05679ccc1500daaec1eb2c913e5041404821ac58be60bfa6560438720

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