How tanvir-mahamood/security-and-privacy works
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 Sig scratch · Man in the Middle Attack MITM attack · encription_main.py CryptoBasics · ciphertext.txt Ciphertext
Components 24
Classical ciphers
Instructional reversible text transformations and the DES/AES-era symmetric examples.
- Plaintext in · Sender-side plaintext used by the CryptoBasics demos.
CryptoBasics/plaintext_sender.txt - CryptoBasics · Educational classical ciphers such as Caesar, substitution, and transposition.
CryptoBasics/encription_main.py - Ciphertext · Encrypted text produced by the CryptoBasics pipeline.
CryptoBasics/ciphertext.txt - Plaintext out · Receiver-side recovered plaintext for the CryptoBasics demos.
CryptoBasics/plaintext_receiver.txt - DES · DES encryption/decryption demonstration.
DES Data Encryption Standard - Triple DES · 3DES encryption/decryption demonstration.
Triple DES - AES · AES encryption/decryption demo with extra debug tracing.
AES Advanced Encryption Standard - Debug log · 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 · RSA message encryption demonstration.
RSA - Diffie-Hellman · Shared-secret establishment and related message artifacts.
Diffie Hellman Algorithm - MITM attack · Three-party interception and tampering simulation layered on key exchange.
Man in the Middle Attack - Alice inbox · Alice-side message artifact used in the MITM demo.
Man in the Middle Attack/Alice_Inbox.txt - Darth recv · Messages received by Darth in the MITM scenario.
Man in the Middle Attack/Darth_Receiving.txt
Hashing
One-way SHA1 digest workflow.
Signatures
Digital signature demos built from hashing plus asymmetric crypto.
- Sig scratch · Scratch implementation of digital signatures.
Digital Signature Scratch - rsa.py · RSA helper used by the scratch signature demo.
Digital Signature Scratch/rsa.py - sha1.py · SHA1 helper used by the scratch signature demo.
Digital Signature Scratch/sha1.py - Sender inbox · Signed payload staging area for the signature demos.
Digital Signature Scratch/sender_inbox.txt - Receiver inbox · Verification output for the signature demos.
Digital Signature Scratch/receiver_inbox.txt - Digital Signature · Higher-level digital signature demo.
Digital Signature - Sender inbox · Sender-side inbox for the packaged signature demo.
Digital Signature/sender_inbox.txt - Receiver inbox · Receiver-side inbox for the packaged signature demo.
Digital Signature/receiver_inbox.txt
Connections 18
- 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.