🏠 Home / Hub

🔐 Cyber Security Lesson 05 — Cryptography

← Back to Security Menu  |  🏠 Hub

1. Symmetric vs Asymmetric Encryption

🔑 Symmetric (Same Key)

Encrypt နဲ့ Decrypt — key တစ်ချောင်းတည်း

✅ Fast (bulk data)
❌ Key sharing problem

Algorithms: AES-256, ChaCha20
Use: File encryption, disk, VPN data

🔑🔑 Asymmetric (Key Pair)

Public Key = Encrypt
Private Key = Decrypt

✅ Safe key exchange
❌ Slower

Algorithms: RSA-2048, ECC
Use: HTTPS, SSH, Email signing

Symmetric Example (AES):
  Encrypt: data + key → ciphertext
  Decrypt: ciphertext + same key → data

Asymmetric Example (RSA):
  Ko gives his Public Key to Ma Ma
  Ma Ma encrypts message with Ko's Public Key
  Only Ko's Private Key can decrypt it!

2. Hashing

Hashing = One-way function → fixed-length output
Encryption ≠ Hashing  (hash ကို decrypt လို့ မရ!)

SHA-256 example:
"hello"      → 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b982
"hello!"     → ce06092fb948d9af6f32f0fddcd83ea3529fc3e62d7c32b6cde285b3b048c58
↑ tiny change → completely different hash (Avalanche effect)

Common hash algorithms:
MD5      — 128-bit — ❌ Broken (collision attacks)
SHA-1    — 160-bit — ❌ Broken
SHA-256  — 256-bit — ✅ Strong (Bitcoin uses this)
SHA-512  — 512-bit — ✅ Very strong
bcrypt   — ✅ Best for passwords (has salt + rounds)
Argon2   — ✅ Winner of Password Hashing Competition
# PHP password hashing
$hash = password_hash("mypassword", PASSWORD_BCRYPT);
// $2y$10$... (includes salt automatically)

$valid = password_verify("mypassword", $hash); // true

# Python
import hashlib
h = hashlib.sha256(b"hello").hexdigest()
🛡️ Passwords ကို NEVER store as plain text, NEVER use MD5/SHA1 for passwords — bcrypt/Argon2 ပဲ သုံး

3. SSL/TLS — HTTPS ဘယ်လို အလုပ်လုပ်သလဲ

TLS Handshake (simplified):
1. Client → Server: "Hello, TLS 1.3 support ရတယ်"
2. Server → Client: Certificate (Public Key ပါတဲ့) ပေး
3. Client: Certificate ကို CA နဲ့ verify လုပ်
4. Client: Session key generate → Server Public Key နဲ့ encrypt ပြီး ပို့
5. Server: Private Key နဲ့ decrypt → session key ရ
6. Both: Symmetric AES key တစ်ချောင်းကို share ပြီး data encrypt

Result: All communication encrypted!
  HTTP  → data plain text (wireshark နဲ့ ဖတ်လို့ ရ)
  HTTPS → encrypted (wireshark မှာ gibberish ပဲ ပြ)
SSL/TLS VersionStatusNote
SSL 2.0 / 3.0❌ BrokenPOODLE, DROWN attacks
TLS 1.0 / 1.1⚠️ DeprecatedDisable on servers
TLS 1.2✅ OKStill widely used
TLS 1.3✅ BestFaster, more secure

4. Digital Signatures

Digital Signature = Document ကို sign လုပ်ပြီး verify လုပ်

How it works:
1. Ko writes document
2. Ko hashes document → SHA-256
3. Ko encrypts hash with his PRIVATE KEY = Signature
4. Sends document + signature

Verification (by Ma Ma):
1. Decrypt signature with Ko's PUBLIC KEY → hash
2. Hash the document herself
3. If hashes match → ✅ Ko did sign it (Authenticity)
                   → ✅ Document unchanged (Integrity)

Real world uses:
📜 Code signing (software downloads)
✉️ Email signing (S/MIME, PGP)
🔗 SSL certificates
₿ Bitcoin transactions

5. PKI — Certificate Authority

PKI = Public Key Infrastructure
CA  = Certificate Authority (trusted third party)

CA examples: DigiCert, Let's Encrypt, Comodo

Chain of Trust:
Root CA (OS/Browser built-in)
  └── Intermediate CA
        └── Website Certificate (mysite.com)

When you visit https://mysite.com:
1. Site shows certificate
2. Browser checks: Is it signed by trusted CA?
3. Certificate expired? Domain match?
4. ✅ Lock icon shows → safe connection

Self-signed certificates:
- Free, instant
- Browser shows "Not secure" warning
- OK for internal/dev use only
Free SSL: Let's Encrypt (certbot) — 90-day auto-renew
Paid SSL: DigiCert, Comodo — longer validity, warranty

6. Cryptography Quick Reference

Use CaseAlgorithm
Password storagebcrypt / Argon2
File encryptionAES-256-GCM
Secure communicationTLS 1.3 (RSA or ECDH key exchange)
Data integrity checkSHA-256 / SHA-512
Digital signatureRSA-2048 / ECDSA
Key agreementDiffie-Hellman / ECDH

← Security 04  |  Next: Security 06 → Tools →

📌 Study Checklist