Educational cryptography and network security concepts in Python
Project description
crypto-12
A pure-Python educational package covering 21 cryptography and network security concepts.
No external dependencies. Works with Python 3.8+.
๐ฆ Package Structure
crypto-12/
โ
โโโ crypto_12/
โ โโโ __init__.py
โ โโโ caesar_cipher.py
โ โโโ monoalphabetic_cipher.py
โ โโโ vigenere_cipher.py
โ โโโ playfair_cipher.py
โ โโโ hill_cipher.py
โ โโโ rail_fence_cipher.py
โ โโโ row_column_transposition.py
โ โโโ rsa_demo.py
โ โโโ diffie_hellman_demo.py
โ โโโ sha1_hash.py
โ โโโ md5_hash.py
โ โโโ gcd_euclidean.py
โ โโโ extended_euclidean.py
โ โโโ multiplicative_inverse.py
โ โโโ affine_cipher.py
โ โโโ columnar_transposition.py
โ โโโ simple_permutation.py
โ โโโ otp_cipher.py
โ โโโ frequency_analysis.py
โ โโโ sql_injection_demo.py
โ โโโ nmap_scan_demo.py
โ
โโโ pyproject.toml
โโโ README.md
๐ Installation
Option 1 โ Install directly (editable/development mode)
pip install .
Option 2 โ Build a distributable wheel, then install
# Install build tool
pip install build
# Build the package
python -m build
# Install the built wheel
pip install dist/crypto_12-0.1.0-py3-none-any.whl
๐ง Usage
After installing, you can import and use any module:
from crypto_12 import caesar_cipher
caesar_cipher.run()
Or call individual functions:
from crypto_12.caesar_cipher import encrypt, decrypt
encrypted = encrypt("HELLO WORLD", 3)
decrypted = decrypt(encrypted, 3)
print(encrypted) # KHOOR ZRUOG
print(decrypted) # HELLO WORLD
๐ Module Reference
Substitution Ciphers
| Module | Description |
|---|---|
caesar_cipher |
Shift cipher โ each letter shifted by a fixed amount |
monoalphabetic_cipher |
Arbitrary fixed substitution using a 26-letter key alphabet |
vigenere_cipher |
Polyalphabetic cipher using a repeating keyword |
playfair_cipher |
Digraph cipher using a 5ร5 key matrix |
hill_cipher |
Linear algebra cipher using a 2ร2 invertible matrix (mod 26) |
affine_cipher |
C = (a*P + b) mod 26 with modular inverse for decryption |
Transposition Ciphers
| Module | Description |
|---|---|
rail_fence_cipher |
Zig-zag pattern writing across N rails |
row_column_transposition |
Write in rows, read columns sorted by key |
columnar_transposition |
Column reordering based on alphabetical key ranking |
simple_permutation |
Rearranges character positions within fixed-length blocks |
Public Key / Key Exchange
| Module | Description |
|---|---|
rsa_demo |
Simplified RSA: key generation, encrypt/decrypt with small primes |
diffie_hellman_demo |
DH key exchange: shared secret agreement over public channel |
Hashing
| Module | Description |
|---|---|
sha1_hash |
Pure-Python SHA-1 implementation (160-bit hash) |
md5_hash |
Pure-Python MD5 implementation (128-bit hash) |
Number Theory / Math Utilities
| Module | Description |
|---|---|
gcd_euclidean |
GCD with step-by-step Euclidean trace |
extended_euclidean |
Extended GCD returning Bezout coefficients |
multiplicative_inverse |
Modular inverse: a * x โก 1 (mod m) |
Cryptanalysis
| Module | Description |
|---|---|
frequency_analysis |
Letter frequency counter + Caesar shift guesser |
otp_cipher |
One-Time Pad simulation using XOR + random key |
Security Awareness (Safe Demos)
| Module | Description |
|---|---|
sql_injection_demo |
Explains SQL injection with safe/vulnerable query comparison |
nmap_scan_demo |
Nmap command reference; prints examples only, no real scanning |
โถ๏ธ Running Individual Modules Interactively
Each module has a run() function with interactive prompts:
python -c "from crypto_12 import vigenere_cipher; vigenere_cipher.run()"
python -c "from crypto_12 import rsa_demo; rsa_demo.run()"
python -c "from crypto_12 import frequency_analysis; frequency_analysis.run()"
โ ๏ธ Disclaimer
- The SHA-1 and MD5 implementations are educational and should not be used for security-critical applications.
- The SQL injection demo performs no real database queries.
- The Nmap demo performs no actual network scans.
- RSA and Diffie-Hellman use small numbers for clarity; real implementations require much larger primes.
๐ License
MIT License โ free to use for learning and educational purposes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crypto_12-0.1.1.tar.gz.
File metadata
- Download URL: crypto_12-0.1.1.tar.gz
- Upload date:
- Size: 27.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a9006aa6610135ef2dfbdea6a7b9ecf061d24d3c63debf3e0554cf522e622a0
|
|
| MD5 |
77128aadf7b0ee61cde51be10e1952cd
|
|
| BLAKE2b-256 |
c578800e518d9d680419e4586ee2b7f63f681fce57d7bedcf062ad3b3af0c7af
|
File details
Details for the file crypto_12-0.1.1-py3-none-any.whl.
File metadata
- Download URL: crypto_12-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1377abcae5daa665530051233f1dd7f3ab2ce4d419c8d03c4fef5fa8764b1e3
|
|
| MD5 |
6b9a301210c4a0e0549ec330eff84e99
|
|
| BLAKE2b-256 |
892baa3bf82f1fc5c2b2a0534cf5e23a126ffa183fe546dc9d30ae75aa81158e
|