DEV Community

Cover image for Introducing the Custom Prime-Based Encryption Proof of Concept
Muhammed Shafin P
Muhammed Shafin P

Posted on

Introducing the Custom Prime-Based Encryption Proof of Concept

By Muhammed Shafin P

January 2026

Overview

I'm excited to share the proof-of-concept implementation of my custom encryption design - a novel approach to cryptographic systems that explores key-driven infinite parameter spaces and multiplicative security layers. This POC demonstrates that the theoretical concepts I've developed can be translated into working code.

Repository: github.com/hejhdiss/custom-encryption-poc

What This POC Demonstrates

This implementation proves several core concepts from my encryption design:

1. Key-Driven Dynamic Parameters

The system generates all encryption parameters deterministically from a user-provided key. Every time you change the key, you get a completely different mathematical universe:

  • Unique modulus values
  • Different exponents
  • Custom character-to-prime mappings

2. Variable-Length Key Support

Unlike traditional systems locked to 128, 256, or 512-bit keys, this POC supports any key length beyond a minimum threshold. This creates a truly infinite key space - mathematically represented as Σ(n=128 to ∞) 2^n possibilities.

3. Character Mapping System

Each character gets mapped to a large prime-based value derived from the key. The system uses SHA-256 hashing to create deterministic "coordinates" for every possible ASCII character, ensuring consistency between encryption and decryption.

4. Modular Exponentiation

The core transformation applies modular exponentiation to mapped values:

cipher_value = (character_map_value)^exponent mod modulus
Enter fullscreen mode Exit fullscreen mode

This creates strong diffusion - small changes in input produce dramatically different outputs.

How It Works

Here's a simplified walkthrough of the encryption process:

Initialization:

  1. User provides a secret key
  2. System generates SHA-256 hash from the key
  3. Hash determines the modulus (10^12 + derived value)
  4. Hash determines the exponent (3-9 range)
  5. System generates 256 unique prime-based mappings for all ASCII characters

Encryption:

  1. Each character in plaintext is converted to its mapped value
  2. Modular exponentiation is applied: mapped_value^exponent mod modulus
  3. Results are stored as large integers
  4. Output can be formatted as hex or bytes

Decryption:

  1. System regenerates the same parameters from the key
  2. For each encrypted value, it searches through the character map
  3. Finds which character produces the matching encrypted value
  4. Reconstructs the original plaintext

Real-World Example

Running the POC with key mySecretKey123 and plaintext Hello World:

Enter your secret key: mySecretKey123
Enter string to encrypt: Hello World

==================================================
ENCRYPTION RESULTS
==================================================
Key Used: mySecretKey123
Modulus:  1000946181578
Exponent: 6
--------------------------------------------------

--------------------------------------------------
[RAW BYTES (Truncated)]:
b' \xdf\xd2\xe3\x02\x81\xbe%|\xdfwK\xc2\xd6|wK\xc2\xd6|\xad\xf1\xa8\x10\xad\x83\x9c\x06N6\x83\xe8`\x93\x1a\xad\xf1\xa8\x10\xad\xa0\x12\xf7\xddkwK\xc2\xd6|'...
--------------------------------------------------
[DECRYPTED RESULT]: Hello World
==================================================
Enter fullscreen mode Exit fullscreen mode

Notice how the two 'l' characters produce identical ciphertext (774bc2d67c) - this is expected behavior since they're the same character encrypted with the same parameters.

Theoretical Foundation

This POC is based on the theoretical framework I detailed in my article: Custom Prime-Based Key-Driven Encryption with Modulus Patterns.

The full theoretical model includes:

  • Multi-map selection systems
  • Key-carried modulus patterns
  • Cascading infinite possibility spaces
  • Multiplicative security through simple operations

This POC implements a simplified version focusing on the core concept: proving that key-driven parameter generation and prime-based mapping can create a functional encryption system.

Important Clarifications

This is Theoretical, Not Practical

Everything claimed about this system is theoretical. The security properties, infinite key spaces, and resistance to attacks are mathematical concepts that have not been validated through:

  • Professional cryptographic review
  • Real-world security testing
  • Cryptanalysis by experts
  • Penetration testing
  • Performance benchmarking at scale

This is a POC, Not Production Software

This code exists solely to demonstrate that the concept works in principle. It is NOT:

  • Optimized for performance
  • Hardened against side-channel attacks
  • Suitable for protecting real data
  • Intended for any production use
  • A replacement for established cryptographic standards

Known Limitations

The current POC has several limitations:

  1. Decryption Performance: The brute-force search through all 256 characters is inefficient
  2. Limited Character Set: Only supports ASCII (0-255)
  3. No Authenticated Encryption: Lacks integrity verification
  4. Collision Handling: Limited error handling for edge cases
  5. Memory Usage: Not optimized for large texts

These limitations are acceptable for a proof-of-concept but would need addressing in any serious implementation.

Why Share This POC?

I'm sharing this implementation for several reasons:

1. Transparency

The cryptographic community values openness. By releasing this POC, I invite scrutiny, feedback, and constructive criticism. If there are flaws in my reasoning or implementation, I want to know.

2. Education

This POC demonstrates how custom cryptographic systems can be built from first principles. It shows the journey from theoretical concept to working code, which can be valuable for students and enthusiasts.

3. Collaboration

Perhaps someone will see potential in these ideas and want to explore them further, optimize the implementation, or identify ways to make the theoretical concepts more practical.

4. Documentation

This serves as a concrete reference for the concepts described in my theoretical article. Code often speaks more clearly than words.

Try It Yourself

The POC is open source and available on GitHub:

Repository: github.com/hejhdiss/custom-encryption-poc

Quick Start:

git clone https://github.com/hejhdiss/custom-encryption-poc.git
cd custom-encryption-poc
python c.py
Enter fullscreen mode Exit fullscreen mode

Enter any key and plaintext to see the system in action. Try different keys and observe how the entire encryption universe changes.

Licensing

This project uses dual licensing to balance openness with attribution:

  • Article & Theoretical Concepts: CC BY-SA 4.0 - Share and adapt with attribution
  • Source Code: GPLv3 - Free to use, modify, and distribute with copyleft

Disclaimer and Responsible Use

DO NOT use this for protecting sensitive data. For real security needs, use established standards:

  • Symmetric Encryption: AES-256
  • Asymmetric Encryption: RSA-4096, ECC
  • Hashing: SHA-256, SHA-3
  • Complete Systems: TLS/SSL, GPG, Signal Protocol

These standards have undergone decades of review, testing, and real-world validation. My POC has undergone none of that.

Feedback and Discussion

I welcome constructive feedback, questions, and discussions about this POC. You can:

Whether you're a cryptography expert who can point out flaws, a student learning about encryption, or someone curious about novel approaches to security, your perspective is valuable.

Conclusion

This proof-of-concept demonstrates that theoretical cryptographic concepts can be implemented and tested. While the journey from "it works in theory" to "it's secure in practice" is long and requires extensive professional review, this POC represents a first step: proving the concept is implementable.

The gap between theoretical possibility and practical security is vast. This POC sits firmly in the "theoretical demonstration" category. But it exists, it works, and it shows that exploring novel approaches to cryptography - even when they remain theoretical - can be both educational and thought-provoking.

I believe in transparency, peer review, and the open exchange of ideas. This POC embodies those values.


Muhammed Shafin P

Original design and implementation

Licensed under CC BY-SA 4.0 (article) and GPLv3 (code)

Top comments (0)