Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crypto_12-0.1.0.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crypto_12-0.1.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file crypto_12-0.1.0.tar.gz.

File metadata

  • Download URL: crypto_12-0.1.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for crypto_12-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e10b8447d80d15a049b3f86348c864479f622a3a85469387f192d863b48fcada
MD5 109bd6223857df27ddddae5f88369111
BLAKE2b-256 8043c2e7a8244234eb6bee393c00fc8b77c93d24f1618672a819939812920d46

See more details on using hashes here.

File details

Details for the file crypto_12-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crypto_12-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for crypto_12-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0059c2551a7a297d9bc5a6605e0055f779617481192f0d4c652c8fcc4cdc1cd1
MD5 0ff00dcdd75e3eaa387a0fe5eeb13498
BLAKE2b-256 1c24d0d11bba52a9d93b8421b27c5947f8e6987ae99b3d87af23691d7a2660fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page