Skip to main content

SHARAG-256: A custom cryptographic hashing algorithm combining SHA-256 compression rounds with complex mathematical randomization using trigonometric, exponential, and factorial functions for enhanced entropy. Designed for experimental blockchain, federated learning, and distributed systems applications.

Project description

SHARAG-256

PyPI version Python License: MIT Downloads

SHARAG-256 is a custom experimental cryptographic hashing algorithm that extends the standard SHA-256 compression framework with an additional complex mathematical randomization layer. It produces a deterministic 256-bit (64-character hexadecimal) digest while incorporating trigonometric, exponential, logarithmic, and factorial transformations during the padding phase for enhanced non-linearity and entropy.

Designed for research applications in blockchain systems, federated learning, and distributed consensus mechanisms, SHARAG-256 serves as an experimental alternative to SHA-256 for non-production security research.

⚠️ Disclaimer: SHARAG-256 is a research algorithm and has not undergone formal cryptographic security auditing. Do not use it in production security-critical systems.


🔬 How It Works

SHARAG-256 extends the SHA-256 pipeline with the following modifications:

  1. Complex Random Padding: Before standard SHA-256 zero-padding, a 6-byte value derived from a complex mathematical function of the first 15 characters of the input is injected. This function combines:

    • sin, tan, cos, exp, log, sqrt, factorial, cosh, gamma, and sum-of-squares over ASCII values.
  2. Chunk Transformation: Each 512-bit chunk undergoes two extra passes:

    • Bitwise XOR flip (alternating bytes XOR'd with 0xFF).
    • Circular right-shift of 5 bits per byte.
  3. Parallel Processing: Chunks are processed in parallel using ThreadPoolExecutor for performance on large inputs.

  4. Output: Final 256-bit hash as a 64-character lowercase hex string.


📦 Installation

pip install sharag256

Requires Python ≥ 3.8. No external dependencies — uses Python standard library only.


🚀 Quick Start

from sharag256 import patentmethod

# Hash a simple string
result = patentmethod("hello world")
print(result)
# Output: 64-character hex digest (e.g., "a3f9b2c1...")

# Hash any string input
digest = patentmethod("Anant Jain - IIIT Delhi 2024")
print(f"Hash: {digest}")
print(f"Length: {len(digest)} chars")  # Always 64

📖 API Reference

patentmethod(message: str) -> str

Computes the SHARAG-256 hash of the input string.

Parameter Type Description
message str Input string to hash

Returns: str — 64-character lowercase hexadecimal digest.

Raises:

  • TypeError if input is not a string (use .decode() on bytes first).

🧪 Examples

from sharag256 import patentmethod
import time

# Example 1: Short string
print(patentmethod("hello"))
# Output: 50f3f3e52df91d27... (64 chars)

# Example 2: Long string
long_msg = "anantehucnjldsnciejur380480" * 5
print(patentmethod(long_msg))

# Example 3: Benchmark timing
messages = [
    "a",
    "hello world",
    "The quick brown fox jumps over the lazy dog",
    "x" * 1000,
    "x" * 10000,
]

for msg in messages:
    start = time.time()
    digest = patentmethod(msg)
    elapsed_ns = (time.time() - start) * 1e9
    print(f"[{len(msg):>5} chars] {digest[:16]}...  {elapsed_ns:.0f} ns")

Sample output:

[    1 chars] 3b1b6e5c9a8f2d0e...  980000 ns
[   11 chars] 7f4a2c1e8b3d6a9f...  1200000 ns
[   43 chars] 2e9c4f8a1b7d3e6c...  1500000 ns
[ 1000 chars] a1b3c5d7e9f2a4b6...  2800000 ns
[10000 chars] 9f8e7d6c5b4a3f2e...  9400000 ns

⚖️ SHARAG-256 vs SHA-256

Property SHA-256 SHARAG-256
Output size 256 bits (64 hex) 256 bits (64 hex)
Standard NIST FIPS 180-4 Custom (research)
Security audited ✅ Yes ❌ Not formally audited
Extra randomization ❌ No ✅ Mathematical entropy layer
Parallel processing ❌ No (sequential) ✅ ThreadPoolExecutor
Dependencies hashlib / sha2 None (stdlib only)
Use case Production systems Research & experimentation
Speed ~100 ns ~1–10 ms

🏗️ Project Structure

sharag256/
├── sharag256/
│   ├── __init__.py      # Public API export
│   └── core.py          # Core SHARAG-256 algorithm
├── tests/
│   └── test_sharag.py   # Unit tests
├── pyproject.toml       # Package metadata
├── README.md            # Documentation
└── LICENSE              # MIT License

🧩 Integration with Rust Projects

Since SHARAG-256 is Python-based, to use it in a Rust project (e.g., a blockchain node), either:

Option A: Call via subprocess from Rust:

use std::process::Command;
let output = Command::new("python3")
    .args(["-c", "from sharag256 import patentmethod; print(patentmethod('data'))"])
    .output()
    .expect("Failed to run sharag256");

Option B: Port the algorithm to Rust and publish on crates.io as sharag256 for native use sharag256::Sharag256;.


👥 Authors

Name Email Affiliation
Anant Jain ritujainanant2810@gmail.com IIIT Delhi
Gauranshi Gupta gauranshigupta2000@gmail.com
Rahul Johari rahul@ipu.ac.in IP University

📜 License

This project is licensed under the MIT License — see LICENSE for details.


🤝 Contributing

  1. Fork the repository.
  2. Create a branch: git checkout -b feature/your-feature.
  3. Commit: git commit -m "Add feature".
  4. Push: git push origin feature/your-feature.
  5. Open a Pull Request on GitHub.

Issues and suggestions: Open an issue


⭐ Citation

If you use SHARAG-256 in academic research, please cite:

@software{sharag256,
  title  = {SHARAG-256: A Custom Hash Function with Mathematical Randomization},
  author = {Jain, Anant and Gupta, Gauranshi and Johari, Rahul},
  year   = {2026},
  url    = {https://pypi.org/project/sharag256/},
}

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

sharag256-0.1.5.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

sharag256-0.1.5-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file sharag256-0.1.5.tar.gz.

File metadata

  • Download URL: sharag256-0.1.5.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for sharag256-0.1.5.tar.gz
Algorithm Hash digest
SHA256 cf90c506454f191f0dc5db434b62252b0ce634ebcb7e5e409194464aba1f32aa
MD5 7f940200c8493bef0b8a13871527e668
BLAKE2b-256 24c540b6c4b037dab436509c4373d377f3fd712340551efee86275891989690c

See more details on using hashes here.

File details

Details for the file sharag256-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: sharag256-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for sharag256-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 89c9985ee4a699ddee1bd1b28b7a9c559b899a8d4021d0cf02b51f9c193423c1
MD5 6d57fe15341f8f5487ff48528189cd2f
BLAKE2b-256 ef91e540040ef912ef54bd89d6b4235fb40442c5720e81d66c07be8f8d710858

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