In a world increasingly reliant on digital security, encryption stands as a silent yet critical guardian of information. This project presents an unconventional yet powerful approach to data encryption — one that draws inspiration from the strategic elegance of chess. By translating the tactical movement of pieces on a chessboard into cryptographic keys, this system provides a unique fusion of game theory, mathematical transformation, and modern cryptography.
This encryption project is not just about protecting data — it's about doing so with a method that is creative, dynamic, and demonstrably secure. Through the integration of AES encryption, structured key generation from real-world chess games, and a fully operational web interface, this system offers both functional reliability and cryptographic resilience.
This project introduces a modular encryption-decryption system that uses game data from real chess matches as the foundation for generating cryptographic keys. It securely encrypts files across various formats (e.g., .pdf, .docx, .jpg, .csv) and protects them behind dynamically generated keys that are:
Mathematically derived from board states
Encrypted using AES-256
Validated with a custom decipher key, and
Protected from brute-force access with a self-deleting 3-attempt policy.
The system is complete with a web interface and a backend built in Python using Flask, SQLite, AES (via PyCryptodome), and secure file handling practices
Each user begins by uploading a file and selecting a pair of players (White and Black) from real chess games stored in .csv format. The system randomly chooses one of their matches and reads the move sequence.
Each move in the selected chess game is transformed into a numeric representation:
Piece-based weight: Pawn = 1, Knight = 3, Bishop = 5, Rook = 7, Queen = 11, King = 13
Board coordinates are mapped into alternating binary form (chessboard-like grid of 1s and 0s)
These mappings form a numerical stream which is condensed into a 3×3 matrix.
To increase randomness and obfuscation:
The matrix undergoes row shifting (1→2→3→1),
Transposition,
Scalar addition to specific rows (+1, +9, +7),
Squaring of elements,
Further transposition and shifting to generate a final numeric matrix.
This matrix is flattened and used to create a SHA-256 digest, producing a cryptographically strong AES-256 key.
Using the 256-bit key, the uploaded file is encrypted with AES in EAX mode (providing both confidentiality and authentication). The final file is stored locally with a .enc extension.
A readable "decipher key" is created based on:
First letters of White and Black players’ names,
Color (W/B),
Digits from the upload date.
This key acts as a required token during decryption, ensuring multi-factor protection that’s human-readable but algorithmically bound to the specific encryption event
AES-256 → 2²⁵⁶ possibilities, making brute force infeasible.
SHA-256 key generation ensures avalanche effect: even one changed move in the game alters the key completely.
Random game selection from multiple .csv files increases entropy dramatically.
The transformations ensure that even if two chess games have identical starting positions or opening moves, the resulting key matrix is highly likely to be unique after hashing.
Each encrypted file allows only 3 decryption attempts.
All attempts are tracked in the database.
After 3 failures, the file is automatically deleted to prevent exhaustive key-guessing.
📊 Integrated Visual Analytics (New Additions):
To provide insight into how encryption is performed, and to demonstrate cryptographic behavior, this project includes multiple secure visualizations:
Each stage of the matrix transformation pipeline is visualized using annotated heatmaps, clearly showing how numeric complexity increases at each step.
The SHA-256-generated key is displayed as a bar chart, showing the entropy and randomness of byte values — validating secure hash behavior.
A simulated table presents anonymized logs of:
Encrypted file IDs
Player combinations used
File formats
Decryption attempts remaining
This is useful for system audits and demonstrating encryption discipline without leaking real user data
🔎 Why This Approach Enhances Security:
While traditional AES encryption is strong, key management is the true weak link. By generating keys from structured, high-entropy input like a chess game:
You eliminate the need to store or transmit static keys.
You increase the uniqueness of encryption.
You create a natural passphrase mechanism (decipher key) that’s both human and algorithm-driven.
Unlike passphrases or PINs, which can be guessed, the decipher key here is deterministically generated but only by those who know:
The exact game used,
The piece colors, and
The upload date digits
Encrypt contracts, medical records, or legal evidence with unique chess-based keys.
Even if two people encrypt the same file, different games yield different results.
Messages encrypted using a selected chess match between two known parties.
Only the right match + decipher key can decrypt it.
Encrypt “treasure files” behind famous games — only chess players or puzzle solvers can decrypt them.
Perfect for demonstrating entropy, matrix transformation, and key generation principles in cryptography courses.
This chess-based encryption project is more than a creative twist on cryptographic principles — it’s a functionally complete, visually insightful, and security-focused encryption tool built for real-world use and educational impact. It proves that key generation doesn’t have to rely on static values or stored secrets — it can arise dynamically from patterns in strategic games, mathematically transformed into secure ciphers.
Whether used in secure document workflows, gamified access control, or academic cryptography demonstrations, this system provides a unique, scalable, and intelligent model of encryption in action