# dangduongminhnhat/cryptography-and-network-security-hcmut architecture

> Architecture diagram of the GitHub repository dangduongminhnhat/cryptography-and-network-security-hcmut, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dangduongminhnhat/cryptography-and-network-security-hcmut
- Repository: https://github.com/dangduongminhnhat/cryptography-and-network-security-hcmut

## Overview

##### Main Components
- Entry Point (main.py): This file is the starting point of the program. It likely handles user input, orchestrates key generation, encryption, decryption, and displays results.
- RSA Implementation Module (rsa_implement.py): This module contains the core RSA algorithm logic, from key generation to encryption and decryption routines.
- Prime Number Generator (sieve_base.py): As suggested by its name, this module probably implements the Sieve of Eratosthenes (or related algorithm) to generate prime numbers, which are essential for choosing the RSA keys.
- Supporting / Auxiliary Files:
- README.md provides documentation and instructions.
- The images folder contains demo screenshots, which might be referenced in the project documentation but do not affect runtime logic.
- __pycache__ is auto-generated for performance optimization and doesn’t represent a design component.

##### Relationships and Interactions
- The program flow begins in main.py where the user runs the program (via “python main.py”).
- main.py calls functions in rsa_implement.py to manage the RSA logic (e.g., generating keys, encryption, decryption).
- Within rsa_implement.py, when prime numbers are required for key generation, the module delegates responsibility to sieve_base.py.
- The data flow is essentially sequential: user input -> main controller -> RSA processing -> use of sieve-based prime generation -> output.
- You may also include error handling paths or logging if there are dedicated functions, though these are not immediately visible from the file tree.

##### Architectural Patterns and Design Principles
- Modularity: The separation of concerns is clear. The project divides the RSA algorithm implementation (rsa_implement.py) from its helper function for prime generation (sieve_base.py), which allows for easier maintenance and potential reusability.
- Reusability and Encapsulation: Each module is dedicated to a specific task, adhering to single responsibility principles.
- Procedural Flow: It follows a relatively simple procedural or layered architecture – a main controller orchestrating calls to helper modules for mathematical operations.

##### Incorporate Relevant Technology
- Python is the primary programming language.
- There is no explicit usage of external libraries mentioned in the README, so the focus is on standard Python modules.
- The use of __pycache__ indicates standard Python optimization practices.

##### Essential Architectural Elements
- Clearly separate the orchestration (main.py) from the computational logic (rsa_implement.py and sieve_base.py).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Flow
    UI["User Interface / Input"]:::ui
    MC["Main Controller (main.py)"]:::core
    RSA["RSA Module (rsa_implement.py)"]:::core
    PG["Prime Generator (sieve_base.py)"]:::utility
    OUT["Output/Result"]:::ui

    UI -->|"start"| MC
    MC -->|"calls_encryption"| RSA
    RSA -->|"calls_for_primes"| PG
    PG -->|"returns_primes"| RSA
    RSA -->|"sends_result"| MC
    MC -->|"displays"| OUT

    %% Documentation Subgraph
    subgraph "Project Documentation"
        DOC["Documentation (README.md)"]:::docs
        IMG["Demo Screenshots (images)"]:::docs
    end

    %% Click Events
    click MC "https://github.com/dangduongminhnhat/cryptography-and-network-security-hcmut/blob/main/main.py"
    click RSA "https://github.com/dangduongminhnhat/cryptography-and-network-security-hcmut/blob/main/rsa_implement.py"
    click PG "https://github.com/dangduongminhnhat/cryptography-and-network-security-hcmut/blob/main/sieve_base.py"
    click DOC "https://github.com/dangduongminhnhat/cryptography-and-network-security-hcmut/blob/main/README.md"
    click IMG "https://github.com/dangduongminhnhat/cryptography-and-network-security-hcmut/tree/main/images"

    %% Styles
    classDef ui fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef core fill:#C9DAF8,stroke:#333,stroke-width:2px;
    classDef utility fill:#D5E8D4,stroke:#333,stroke-width:2px;
    classDef docs fill:#FFF2CC,stroke:#333,stroke-width:2px;
```
