# tanvir-mahamood/security-and-privacy architecture

> Architecture diagram of the GitHub repository tanvir-mahamood/security-and-privacy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tanvir-mahamood/security-and-privacy
- Repository: https://github.com/tanvir-mahamood/security-and-privacy

## Overview

1. **Repository shape**
   - This is an educational, algorithm-by-algorithm cryptography repo rather than a single integrated application.
   - Each algorithm lives in its own top-level folder and is mostly self-contained, with no shared runtime package or common service layer.

2. **Primary architectural boundary: per-algorithm sandboxes**
   - The main boundary is the directory per algorithm: CryptoBasics, DES, Triple DES, AES, RSA, Diffie-Hellman, Man in the Middle Attack, SHA1, and Digital Signature variants.
   - Each sandbox has its own script entrypoint and its own text files, so data does not appear to flow across algorithm folders.

3. **Common execution model**
   - Most cryptography modules use `encription_main.py` as the entry script.
   - SHA1 uses `main.py`, and the signature demos use `main.py` plus helper modules.
   - The repo is organized around running a script, reading an input text file, producing an output file, and then optionally writing a decrypted or verified result back to another file.

4. **File-based data flow**
   - The standard pattern is:
     - sender-side plaintext input
     - ciphertext output
     - receiver-side plaintext output
   - This pattern appears repeatedly in `plaintext_sender.txt`, `ciphertext.txt`, and `plaintext_receiver.txt`.
   - The file system is the main integration point, not APIs, network sockets, or databases.

5. **Classical cryptography subsystem**
   - `CryptoBasics` contains the simpler instructional ciphers: Caesar, monoalphabetic substitution, and columnar transposition.
   - This module is likely the entry point for demonstrating reversible text transformations before moving to modern encryption schemes.
   - Its outputs follow the same sender/ciphertext/receiver file loop as the other symmetric encryption demos.

6. **Symmetric encryption subsystem**
   - `DES Data Encryption Standard`, `Triple DES`, and `AES Advanced Encryption Standard` form a symmetric-key cluster.
   - These modules each accept plaintext, apply block encryption, and emit ciphertext, then show the reverse path back to plaintext.
   - AES additionally includes `aes_debug_log.txt`, which suggests internal tracing or step-level visibility for educational/debug use.
   - The README documents `pycryptodome` as the external dependency, which is the only notable third-party library mentioned.

7. **Public-key and key-exchange subsystem**
   - `RSA` demonstrates asymmetric encryption with separate sender/receiver plaintext and ciphertext files.
   - `Diffie Hellman Algorithm` models shared-secret establishment rather than message encryption alone, but it uses the same file-based workflow to show exchanged values and resulting ciphertext-like artifacts.
   - These folders represent the shift from shared-key encryption to public-key and key-agreement concepts.

8. **Security attack demonstration**
   - `Man in the Middle Attack` is a separate scenario module built around Alice, Bob, and Darth.
   - The inbox files (`Alice_Inbox.txt`, `Bob_Inbox.txt`, `Darth_Receiving.txt`, `Darth_Sending.txt`) indicate a three-party message relay rather than a standard encrypt/decrypt pipeline.
   - Architecturally, this folder is a vulnerability simulation layered on top of the Diffie-Hellman concept.

9. **Hashing subsystem**
   - `SHA1` is the non-reversible hashing branch of the repo.
   - It uses `message.txt` as input and `hash.txt` as the output digest artifact, with `test.py` likely used to validate the implementation.
   - Unlike the encryption folders, this module does not have a receiver-plaintext restoration step because hashing is one-way.

10. **Digital signature subsystem**
   - `Digital Signature Scratch` and `Digital Signature` form a separate authenticity/integrity flow.
   - The scratch version includes `rsa.py` and `sha1.py`, showing that signatures are composed from hashing plus RSA-style asymmetric operations.
   - The inbox files (`sender_inbox.txt`, `receiver_inbox.txt`) indicate signed message exchange and verification rather than raw encryption.

11. **Overall data relationship**
   - The repo’s core pattern is: input text or message file → algorithm script → output artifact file.
   - Depending on the algorithm, the output is either ciphertext, hash, or signed/verified message content.
   - There is no evidence of persistent storage, user interfaces, or networked services; all state is represented by files.

12. **How to diagram it**
   - A clear architecture diagram would show one top-level “educational cryptography collection” box containing independent algorithm modules.
   - Inside each module, show a local file input, a single script entrypoint, and a file output.
   - Highlight three conceptual branches: symmetric encryption, public-key/key exchange, and hashing/signatures, with the MITM folder as an attack demo on the key-exchange branch.

Main entry points: [`Digital Signature Scratch`](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/Digital%20Signature%20Scratch) (Sig scratch), [`Man in the Middle Attack`](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/Man%20in%20the%20Middle%20Attack) (MITM attack), [`CryptoBasics/encription_main.py`](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/encription_main.py) (CryptoBasics), [`CryptoBasics/ciphertext.txt`](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/ciphertext.txt) (Ciphertext)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_classical["Classical ciphers"]
  node_crypto_basics_sender["Plaintext in<br/>input file"]
  node_crypto_basics_main["CryptoBasics<br/>cipher sandbox<br/>[encription_main.py]"]
  node_crypto_basics_cipher["Ciphertext<br/>output file<br/>[ciphertext.txt]"]
  node_crypto_basics_receiver["Plaintext out<br/>output file"]
  node_des_sandbox["DES<br/>symmetric sandbox"]
  node_triple_des_sandbox["Triple DES<br/>symmetric sandbox"]
  node_aes_sandbox["AES<br/>symmetric sandbox"]
  node_aes_debug_log["Debug log<br/>trace file<br/>[aes_debug_log.txt]"]
end

subgraph group_public_key["Public key"]
  node_rsa_sandbox["RSA<br/>asymmetric sandbox"]
  node_dh_sandbox["Diffie-Hellman<br/>key exchange sandbox"]
  node_mitm_sandbox["MITM attack<br/>attack scenario"]
  node_alice_inbox["Alice inbox<br/>message file<br/>[Alice_Inbox.txt]"]
  node_darth_recv["Darth recv<br/>relay file"]
end

subgraph group_hashing["Hashing"]
  node_sha1_msg["Message<br/>input file<br/>[message.txt]"]
  node_sha1_main["SHA1<br/>hash pipeline<br/>[main.py]"]
  node_sha1_hash["Digest<br/>hash output<br/>[hash.txt]"]
end

subgraph group_signatures["Signatures"]
  node_sig_scratch["Sig scratch<br/>signature pipeline"]
  node_sig_rsa["rsa.py<br/>helper module<br/>[rsa.py]"]
  node_sig_sha1["sha1.py<br/>helper module<br/>[sha1.py]"]
  node_sig_sender["Sender inbox<br/>signed message file<br/>[sender_inbox.txt]"]
  node_sig_receiver["Receiver inbox<br/>verification file<br/>[receiver_inbox.txt]"]
  node_sig_main["Digital Signature<br/>signature pipeline"]
  node_sig_main_sender["Sender inbox<br/>signed message file<br/>[sender_inbox.txt]"]
  node_sig_main_receiver["Receiver inbox<br/>verification file<br/>[receiver_inbox.txt]"]
end

node_crypto_basics_sender -->|"plaintext"| node_crypto_basics_main
node_crypto_basics_main -->|"ciphertext"| node_crypto_basics_cipher
node_crypto_basics_cipher -->|"decrypt"| node_crypto_basics_receiver
node_des_sandbox -->|"family"| node_triple_des_sandbox
node_triple_des_sandbox -->|"evolution"| node_aes_sandbox
node_aes_sandbox -.->|"trace"| node_aes_debug_log
node_rsa_sandbox -->|"public-key"| node_dh_sandbox
node_dh_sandbox -->|"threat model"| node_mitm_sandbox
node_mitm_sandbox -->|"alice"| node_alice_inbox
node_mitm_sandbox -->|"intercept"| node_darth_recv
node_sha1_msg -->|"hash input"| node_sha1_main
node_sha1_main -->|"digest"| node_sha1_hash
node_sig_scratch -->|"uses"| node_sig_rsa
node_sig_scratch -->|"uses"| node_sig_sha1
node_sig_sender -->|"sign"| node_sig_scratch
node_sig_scratch -->|"verify"| node_sig_receiver
node_sig_main_sender -->|"sign"| node_sig_main
node_sig_main -->|"verify"| node_sig_main_receiver

click node_crypto_basics_sender "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/plaintext_sender.txt"
click node_crypto_basics_main "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/encription_main.py"
click node_crypto_basics_cipher "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/ciphertext.txt"
click node_crypto_basics_receiver "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/plaintext_receiver.txt"
click node_des_sandbox "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/DES Data Encryption Standard"
click node_triple_des_sandbox "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/Triple DES"
click node_aes_sandbox "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/AES Advanced Encryption Standard"
click node_aes_debug_log "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/AES Advanced Encryption Standard/aes_debug_log.txt"
click node_rsa_sandbox "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/RSA"
click node_dh_sandbox "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/Diffie Hellman Algorithm"
click node_mitm_sandbox "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/Man in the Middle Attack"
click node_alice_inbox "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Man in the Middle Attack/Alice_Inbox.txt"
click node_darth_recv "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Man in the Middle Attack/Darth_Receiving.txt"
click node_sha1_msg "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/SHA1/message.txt"
click node_sha1_main "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/SHA1/main.py"
click node_sha1_hash "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/SHA1/hash.txt"
click node_sig_scratch "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/Digital Signature Scratch"
click node_sig_rsa "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Digital Signature Scratch/rsa.py"
click node_sig_sha1 "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Digital Signature Scratch/sha1.py"
click node_sig_sender "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Digital Signature Scratch/sender_inbox.txt"
click node_sig_receiver "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Digital Signature Scratch/receiver_inbox.txt"
click node_sig_main "https://github.com/tanvir-mahamood/security-and-privacy/tree/main/Digital Signature"
click node_sig_main_sender "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Digital Signature/sender_inbox.txt"
click node_sig_main_receiver "https://github.com/tanvir-mahamood/security-and-privacy/blob/main/Digital Signature/receiver_inbox.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_crypto_basics_sender,node_crypto_basics_main,node_crypto_basics_cipher,node_crypto_basics_receiver,node_des_sandbox,node_triple_des_sandbox,node_aes_sandbox,node_aes_debug_log toneBlue
class node_rsa_sandbox,node_dh_sandbox,node_mitm_sandbox,node_alice_inbox,node_darth_recv toneAmber
class node_sha1_msg,node_sha1_main,node_sha1_hash toneMint
class node_sig_scratch,node_sig_rsa,node_sig_sha1,node_sig_sender,node_sig_receiver,node_sig_main,node_sig_main_sender,node_sig_main_receiver toneRose
```

## Components

### Classical ciphers

Instructional reversible text transformations and the DES/AES-era symmetric examples.

- [Plaintext in](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/plaintext_sender.txt): input file · Sender-side plaintext used by the CryptoBasics demos. · `CryptoBasics/plaintext_sender.txt`
- [CryptoBasics](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/encription_main.py): cipher sandbox · Educational classical ciphers such as Caesar, substitution, and transposition. · `CryptoBasics/encription_main.py`
- [Ciphertext](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/ciphertext.txt): output file · Encrypted text produced by the CryptoBasics pipeline. · `CryptoBasics/ciphertext.txt`
- [Plaintext out](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/CryptoBasics/plaintext_receiver.txt): output file · Receiver-side recovered plaintext for the CryptoBasics demos. · `CryptoBasics/plaintext_receiver.txt`
- [DES](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/DES%20Data%20Encryption%20Standard): symmetric sandbox · DES encryption/decryption demonstration. · `DES Data Encryption Standard`
- [Triple DES](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/Triple%20DES): symmetric sandbox · 3DES encryption/decryption demonstration. · `Triple DES`
- [AES](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/AES%20Advanced%20Encryption%20Standard): symmetric sandbox · AES encryption/decryption demo with extra debug tracing. · `AES Advanced Encryption Standard`
- [Debug log](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/AES%20Advanced%20Encryption%20Standard/aes_debug_log.txt): trace file · Internal AES step log for educational visibility. · `AES Advanced Encryption Standard/aes_debug_log.txt`

### Public key

RSA, Diffie-Hellman, and the MITM attack scenario.

- [RSA](https://github.com/tanvir-mahamood/security-and-privacy/tree/main/RSA): asymmetric sandbox · RSA message encryption demonstration. · `RSA`
- [Diffie-Hellman](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/Diffie%20Hellman%20Algorithm): key exchange sandbox · Shared-secret establishment and related message artifacts. · `Diffie Hellman Algorithm`
- [MITM attack](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/Man%20in%20the%20Middle%20Attack): attack scenario · Three-party interception and tampering simulation layered on key exchange. · `Man in the Middle Attack`
- [Alice inbox](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Man%20in%20the%20Middle%20Attack/Alice_Inbox.txt): message file · Alice-side message artifact used in the MITM demo. · `Man in the Middle Attack/Alice_Inbox.txt`
- [Darth recv](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Man%20in%20the%20Middle%20Attack/Darth_Receiving.txt): relay file · Messages received by Darth in the MITM scenario. · `Man in the Middle Attack/Darth_Receiving.txt`

### Hashing

One-way SHA1 digest workflow.

- [Message](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/SHA1/message.txt): input file · Input message hashed by SHA1. · `SHA1/message.txt`
- [SHA1](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/SHA1/main.py): hash pipeline · SHA1 implementation entrypoint. · `SHA1/main.py`
- [Digest](https://github.com/tanvir-mahamood/security-and-privacy/blob/main/SHA1/hash.txt): hash output · SHA1 digest output artifact. · `SHA1/hash.txt`

### Signatures

Digital signature demos built from hashing plus asymmetric crypto.

- [Sig scratch](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/Digital%20Signature%20Scratch): signature pipeline · Scratch implementation of digital signatures. · `Digital Signature Scratch`
- [rsa.py](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Digital%20Signature%20Scratch/rsa.py): helper module · RSA helper used by the scratch signature demo. · `Digital Signature Scratch/rsa.py`
- [sha1.py](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Digital%20Signature%20Scratch/sha1.py): helper module · SHA1 helper used by the scratch signature demo. · `Digital Signature Scratch/sha1.py`
- [Sender inbox](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Digital%20Signature%20Scratch/sender_inbox.txt): signed message file · Signed payload staging area for the signature demos. · `Digital Signature Scratch/sender_inbox.txt`
- [Receiver inbox](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Digital%20Signature%20Scratch/receiver_inbox.txt): verification file · Verification output for the signature demos. · `Digital Signature Scratch/receiver_inbox.txt`
- [Digital Signature](https://github.com/tanvir-mahamood/security-and-privacy/tree/HEAD/Digital%20Signature): signature pipeline · Higher-level digital signature demo. · `Digital Signature`
- [Sender inbox](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Digital%20Signature/sender_inbox.txt): signed message file · Sender-side inbox for the packaged signature demo. · `Digital Signature/sender_inbox.txt`
- [Receiver inbox](https://github.com/tanvir-mahamood/security-and-privacy/blob/HEAD/Digital%20Signature/receiver_inbox.txt): verification file · Receiver-side inbox for the packaged signature demo. · `Digital Signature/receiver_inbox.txt`

## Connections

- Plaintext in → CryptoBasics: plaintext · Classical ciphers consume sender plaintext.
- CryptoBasics → Ciphertext: ciphertext · The script emits encrypted text.
- Ciphertext → Plaintext out: decrypt · Receiver-side output completes the reversible loop.
- DES → Triple DES: family · DES and 3DES form the symmetric-key cluster.
- Triple DES → AES: evolution · AES is the later symmetric block cipher in the same teaching path.
- AES → Debug log: trace · AES writes step-level debug output.
- RSA → Diffie-Hellman: public-key · RSA and Diffie-Hellman show different public-key concepts.
- Diffie-Hellman → MITM attack: threat model · The MITM demo attacks the key-exchange scenario.
- MITM attack → Alice inbox: alice · Alice-side relay artifact in the attack scenario.
- MITM attack → Darth recv: intercept · Darth receives and relays messages in the attack flow.
- Message → SHA1: hash input · SHA1 reads a message file and computes a digest.
- SHA1 → Digest: digest · SHA1 produces a one-way hash artifact.
- Sig scratch → rsa.py: uses · The scratch signature implementation composes RSA operations.
- Sig scratch → sha1.py: uses · The scratch signature implementation composes SHA1 hashing.
- Sender inbox → Sig scratch: sign · Sender-side input enters the signature pipeline.
- Sig scratch → Receiver inbox: verify · Verification results are written to the receiver inbox.
- Sender inbox → Digital Signature: sign · Packaged signature demo starts from sender inbox content.
- Digital Signature → Receiver inbox: verify · Verified or checked content is written to the receiver inbox.
