CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument

I’m a self-taught cryptography enthusiast and high school graduate who loves exploring the intersection of mathematics and programming.
This is the story behind CantorCipher— a lightweight, educational encryption algorithm I built from scratch using id…


This content originally appeared on DEV Community and was authored by Armin Memar

I’m a self-taught cryptography enthusiast and high school graduate who loves exploring the intersection of mathematics and programming.
This is the story behind CantorCipher— a lightweight, educational encryption algorithm I built from scratch using ideas from Cantor’s diagonal argument and Boolean logic.

Why I Created CantorCipher
During my study of cryptographic concepts, I became fascinated with how mathematics can drive real-world technology. One particular concept stuck with me: Cantor’s diagonal argument — a brilliant proof technique from set theory that shows how infinities can be “bigger” than other infinities.

It made me think:

What if we used diagonalization to create structure and uniqueness in cryptography?

That’s when the idea for CantorCipher was born — a symmetric block cipher that mixes bits based on mathematical rules, using Boolean logic and custom-designed bit mixing. I wanted something simple, deterministic, and mathematically elegant!

What Is CantorCipher?
CantorCipher is a symmetric encryption algorithm that:

  • Converts messages and keys into binary
  • Applies several rounds of Boolean logic mixing (XOR, AND, NOT, etc.)
  • Uses diagonal-based patterns to compute an authentication tag
  • Supports both encryption and decryption in Python

It’s not designed to compete with AES or ChaCha, but rather to show how encryption can be built creatively using bit-level logic and mathematical structure.

Core Design

  • Boolean Logic: The cipher is built on fundamental logic operations like XOR, AND, and custom nonlinear bit rules.
  • Diagonalization: A metaphorical application of Cantor’s diagonal method to ensure message–key uniqueness in tag generation.
  • Bit Mixing: Rotations, permutations, and multi-round mixing create diffusion and a basic avalanche effect.
  • Symmetry: The same operations decrypt what was encrypted, keeping it simple.

Features

  • Pure Python, no dependencies
  • Custom authentication tag to detect tampering
  • Designed to teach encryption basics and mathematical reasoning
  • Mathematically inspired — not just a cipher, but a learning tool
  • Includes basic test cases for validation

Try It Out
You can find the project here:
github.com/ArminMemar/CantorCipher
It includes:

  • cantor_cipher.py: the encryption/decryption implementation
  • test_cantor_cipher.py: basic tests
  • README.md: everything explained clearly

All you need is Python 3.

What’s Next?
CantorCipher was just the beginning of my journey into cryptography. I plan to keep exploring how mathematics can power secure communication.

About Me
I’m a high school graduate who loves math, programming, and making new things. I’m exploring cryptography and computational theory through personal projects like CantorCipher.

Final Thoughts
I built CantorCipher because I love math, code, and turning ideas into experiments.

  • If You Like This:
  • Star CantorCipher on GitHub
  • Comment or suggest improvements
  • Share this post with anyone interested in crypto, math, or original ideas

Thanks for reading!


This content originally appeared on DEV Community and was authored by Armin Memar


Print Share Comment Cite Upload Translate Updates
APA

Armin Memar | Sciencx (2025-08-02T15:29:44+00:00) CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument. Retrieved from https://www.scien.cx/2025/08/02/cantorcipher-a-personal-encryption-project-inspired-by-cantors-diagonal-argument/

MLA
" » CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument." Armin Memar | Sciencx - Saturday August 2, 2025, https://www.scien.cx/2025/08/02/cantorcipher-a-personal-encryption-project-inspired-by-cantors-diagonal-argument/
HARVARD
Armin Memar | Sciencx Saturday August 2, 2025 » CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument., viewed ,<https://www.scien.cx/2025/08/02/cantorcipher-a-personal-encryption-project-inspired-by-cantors-diagonal-argument/>
VANCOUVER
Armin Memar | Sciencx - » CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/02/cantorcipher-a-personal-encryption-project-inspired-by-cantors-diagonal-argument/
CHICAGO
" » CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument." Armin Memar | Sciencx - Accessed . https://www.scien.cx/2025/08/02/cantorcipher-a-personal-encryption-project-inspired-by-cantors-diagonal-argument/
IEEE
" » CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument." Armin Memar | Sciencx [Online]. Available: https://www.scien.cx/2025/08/02/cantorcipher-a-personal-encryption-project-inspired-by-cantors-diagonal-argument/. [Accessed: ]
rf:citation
» CantorCipher: A Personal Encryption Project Inspired by Cantor’s Diagonal Argument | Armin Memar | Sciencx | https://www.scien.cx/2025/08/02/cantorcipher-a-personal-encryption-project-inspired-by-cantors-diagonal-argument/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.