Cyber Security Notes— Modules 7
CYBER SECURITY NOTES
Study Notes — Modules 7
Intermediate Phase
Module 7 — Cryptography Basics
Page 1
Cyber Security Notes— Modules 7
MODULE 7 — Cryptography Basics
Sessions 69–78 | Duration: 15 hours | Phase: Intermediate
7.1 Why Encryption Matters
Encryption transforms readable data ('plaintext') into an unreadable form ('ciphertext') using a mathematical
algorithm and a key, so that only someone with the correct key can reverse the process and read the original
data.
What Encryption Protects Against
• Eavesdropping — an attacker intercepting network traffic (e.g., on public Wi-Fi, Module 3) sees only
ciphertext.
• Data theft — a stolen laptop or drive with encrypted storage remains unreadable without the key.
• Tampering — many encryption schemes also verify that data was not altered in transit.
Connects back to the CIA Triad (Module 1):
Encryption is the primary technical control for Confidentiality — and, when combined with integrity checks,
also supports the Integrity pillar.
7.2 Symmetric vs Asymmetric Encryption
Aspect Symmetric Encryption Asymmetric Encryption
Keys used One single shared key for both A key pair — a public key (shared) and a
encryption and decryption private key (secret)
Speed Fast — suited to large volumes of data Slower — computationally heavier
Key distribution problem Both parties must securely share the Only the public key needs to be shared;
same secret key beforehand the private key never leaves its owner
Common Algorithms AES, ChaCha20, (legacy: DES/3DES) RSA, ECC (Elliptic Curve Cryptography)
Typical Use Encrypting files, disk encryption, bulk Key exchange, digital signatures,
data in VPNs securing the initial handshake in HTTPS
How they work together in HTTPS:
In practice, HTTPS uses asymmetric encryption to safely exchange a temporary symmetric key, then switches
to fast symmetric encryption for the actual session data — combining the security of asymmetric methods
with the speed of symmetric ones.
7.3 Hashing vs Encryption
Hashing and encryption are often confused, but they serve different purposes.
Property Encryption Hashing
Reversible? Yes — with the correct key No — designed to be one-way
Page 8
Cyber Security Notes— Modules 7
Property Encryption Hashing
Purpose Confidentiality — hide the content of Integrity verification — prove data has
data not changed; store passwords securely
Output length Varies with input length Fixed length regardless of input size
Common Algorithms AES, RSA SHA-256, SHA-3, (legacy/insecure: MD5,
SHA-1)
Command Examples — Generating a Hash
# Windows PowerShell
Get-FileHash [Link] -Algorithm SHA256
# Linux / macOS
sha256sum [Link]
echo -n "Hello World" | sha256sum
Sample output:
a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e [Link]
Why passwords are hashed, not encrypted:
A well-designed system stores only the hash of a password, never the password itself or its encrypted form.
When you log in, the system hashes what you typed and compares hashes — so even if the database is stolen,
the original passwords are not directly recoverable.
7.4 Classical Ciphers — Caesar Cipher & Substitution Cipher
Caesar Cipher
One of the oldest known ciphers: each letter in the plaintext is shifted a fixed number of positions along the
alphabet.
Plaintext: H E L L O
Shift: +3
Ciphertext: K H O O R
Simple Python implementation:
def caesar_encrypt(text, shift):
result = ""
for char in text:
if [Link]():
base = ord('A') if [Link]() else ord('a')
result += chr((ord(char) - base + shift) % 26 + base)
else:
result += char
return result
Page 9
Cyber Security Notes— Modules 7
print(caesar_encrypt("HELLO", 3)) # Output: KHOOR
Substitution Cipher
Instead of a fixed shift, each letter of the alphabet is mapped to a different, randomly chosen letter using a
substitution key (a full alphabet-to-alphabet mapping).
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M
Why classical ciphers are insecure today:
Both are vulnerable to frequency analysis (some letters appear far more often than others in any language)
and brute force — a Caesar cipher has only 25 possible shifts, all of which can be tried in seconds by hand, let
alone by a computer.
7.5 HTTPS and Certificates — How the Padlock Icon Works
A digital certificate cryptographically proves that a public key genuinely belongs to the website claiming it,
preventing impersonation.
Simplified TLS Handshake
10. Browser connects to the server and requests its certificate.
11. Server sends its TLS certificate, containing its public key and identity, signed by a trusted Certificate
Authority (CA).
12. Browser verifies the certificate's signature against a list of trusted CAs and checks it hasn't expired or been
revoked.
13. Browser and server use asymmetric encryption to agree on a temporary symmetric session key.
14. All further communication is encrypted with that fast symmetric key — shown to the user as the padlock
icon.
Inspecting a Certificate — Browser Method
• Click the padlock icon in the address bar → 'Connection is secure' → 'Certificate is valid' to view issuer,
validity dates, and domain.
Inspecting a Certificate — Command Line
openssl s_client -connect [Link] -servername [Link] </dev/null
2>/dev/null | openssl x509 -noout -issuer -subject -dates
Sample output:
issuer=C=US, O=Let's Encrypt, CN=R3
subject=CN=[Link]
notBefore=Jan 10 00:00:00 2026 GMT
notAfter=Apr 10 23:59:59 2026 GMT
• issuer = the Certificate Authority that vouched for this website.
Page 10
Cyber Security Notes— Modules 7
• notBefore / notAfter = the validity window; an expired certificate should never be trusted.
7.6 Hands-On Labs & Activities — Module 7
🧪 Hands-On Lab Activities
• Encode and decode messages by hand using the Caesar cipher with a partner (swap shift values).
• Encode and decode messages using a custom substitution cipher key.
• Write a simple script (Python or similar) to encrypt and decrypt text using the Caesar cipher.
• Inspect a real website's HTTPS certificate (issuer, validity dates, domain match) using the browser
method.
• Module 7 recap activity and quiz.
Module 7 — Key Takeaways
• Encryption is reversible with the correct key (confidentiality); hashing is one -way (integrity/password
storage).
• Symmetric encryption is fast and uses one shared key; asymmetric encryption uses a public/private key
pair and solves the key-distribution problem.
• HTTPS combines both: asymmetric encryption to exchange a session key, then symmetric encryption for
the actual data.
• Classical ciphers (Caesar, substitution) illustrate core cryptographic concepts but are trivially breakable
today — modern systems use AES, RSA, and SHA-256/SHA-3 instead.
• A valid HTTPS certificate, signed by a trusted CA, is what the padlock icon actually represents — always
check it before trusting a site.
Page 11