How coduri/visualcrypto works
Project Type and Purpose
• VisualCrypto is an open-source toolkit that implements image-based secret sharing techniques. It supports both Visual Cryptography (VC) and Random Grid (RG) methods, specifically focusing on (2,2)-VSS schemes.
• It is designed to be used in two ways: via standalone Python scripts for direct algorithm execution and through a user-friendly web interface for interactive encryption/decryption.
Analyzing the File Structure
• Top-Level Components:
• The "web_app" directory contains the web interface components (e.g., Flask app, HTML templates, static assets like CSS and images).
• The "scripts" directory is subdivided into folders for specific algorithm implementations:
⁃ "scripts/visual_cryptography" holds the VC methods implementations.
• The "docs" folder includes documentation (with assets and markdown pages created by MkDocs) which offers a user guide, API reference, and other documentation pages.
• Additionally, configuration and support files such as the GitHub workflow YAMLs (in .github), requirements.txt, and mkdocs.yml indicate continuous integration and documentation configuration.
To effectively represent the architecture of VisualCrypto, follow these guidelines:
a. Main Components:
• Web Application Layer (web_app): This contains
• The entry point (app.py) to run the web server.
• Algo interface (algo_interface.py), which bridges user interactions to underlying cryptographic algorithms.
• Templates and static assets that render the UI.
• Cryptographic Algorithms Module (scripts directory):
• Two main sub-modules: one for Random Grid (RG) techniques and one for Visual Cryptography (VC) techniques. Each contains several Python scripts implementing different flavors of encryption (e.g., halftone, grayscale, etc.).
• Documentation & CI/CD:
• Documentation is managed through MkDocs (mkdocs.yml) and stored in docs/.
• CI pipelines are defined within the .github/workflows directory.
b. Relationships and Interactions:
• The web interface forwards user requests (such as image uploads and encryption/decryption commands) to the algo_interface, which then calls the corresponding cryptographic functions in the scripts.
• The Python scripts (in scripts/) perform the core algorithm computations (e.g., splitting the image, reconstructing the secret).
• The output from these processes is relayed back to the web interface for display or returned as downloadable images.
• The system’s documentation and build process (MkDocs and GitHub CI) support continuous updates and testing.
c. Architectural Patterns/Design Principles:
• Separation of Concerns: Clear division between the web presentation layer (handling UI and HTTP requests) and the computation layer (cryptographic algorithms).
• Modularity: The project allows easy extension by adding new algorithms (extensible structure in the scripts/ directories) without altering the web interface.
• Reusability: Common functions can be shared between the algorithm implementations invoked both from scripts and the web_app.
d. Relevant Technologies:
• Python (3.8+ is required) is the primary programming language.
• A web framework (Flask, as suggested by the typical file structure for a small Python web app) is used for the web interface.
• HTML/CSS for the frontend UI components.
• GitHub Actions for CI/CD and MkDocs for documentation building.
Elements
• Clearly labeled components:
– "Web Interface" (including app.py, templates, static assets).
– "Algorithm Module" (with separate blocks for Random Grid and Visual Cryptography algorithms).
– "Documentation & CI" (MkDocs, GitHub Actions).
– A request/response cycle from the user through the web application to the algorithm executions.
– Data flows such as image upload input, processing output, and the communication between algo_interface and script modules.
• Annotations highlighting the use of design principles like modularity, separation of concerns, and extendability.