Skip to content

Session 1: Introduction & Cryptography

File Hashing

File hashing generates a unique fixed-length fingerprint of any file. Even a tiny change completely alters the hash (avalanche effect), making tampering immediately detectable.

Commands:

# Create a test file
echo "Hello Fab Futures Cybersecurity" > test.txt

# Compute SHA256 hash (original)
sha256sum test.txt

# Modify the file
echo "This line was added" >> test.txt

# Compute hash again
sha256sum test.txt

# Save hash for verification
sha256sum test.txt > test.txt.sha256

# Verify integrity
sha256sum -c test.txt.sha256

Results:

State SHA256 Hash
Original d4aaa4e15ef585cddba10ffe938d804332a2fe1a248ee7d9eb60231160d98e4f
After modification 5ba0721e897db996bcbadfb17b903e4ceddfb632b19fea8fa36947e698f1cc6a

Verification result: test.txt: OK

Key takeaways: - A hash function produces a unique fingerprint for any file - Even one added line completely changes the hash — this is the avalanche effect - Distributing a .sha256 file alongside a download lets anyone verify the file wasn’t tampered with - The hash file itself must be distributed securely, otherwise an attacker could replace both


Public/Private Key Pair

Generated an ED25519 key pair — a modern elliptic curve algorithm, faster and more secure than RSA.

Command:

ssh-keygen -t ed25519 -C "sedat.yalcin@hisarschool.k12.tr"

Public key (safe to share):

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF/8/khOpZ/V0Nm6c5+F8ADApN5aOXe47Ahm/53uhScO sedat.yalcin@hisarschool.k12.tr

Key fingerprint:

256 SHA256:+Sz1GS+PXcNxWCqmf9Vgd5U5E8fuZloRB0qH8ZrZkR4 (ED25519)

Files created:

File Location Description
Private key /home/ubuntu/.ssh/id_ed25519 Never shared
Public key /home/ubuntu/.ssh/id_ed25519.pub Safe to distribute

Key takeaways: - The private key never leaves your machine - The public key can be placed on any server to grant access - The fingerprint is used to verify you’re connecting to the correct server - ED25519 (256-bit) is equivalent in strength to RSA 3072-bit


SSH Key Authentication

Installed the public key on the server and authenticated without a password.

Commands:

# Install public key on server
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

# Connect using key (no password prompt)
ssh -i ~/.ssh/id_ed25519 ubuntu@192.168.80.104

Result: Connected successfully without a password.

How it works: 1. The server sends a challenge encrypted with your public key 2. Your client decrypts it using the private key 3. This proves your identity without ever sending a password over the network

What lives where:

Location File Contents
Server ~/.ssh/authorized_keys Public key
Client ~/.ssh/id_ed25519 Private key — never leaves the machine

Security advantage over passwords: A password can be guessed or stolen. A private key is mathematically infeasible to derive from the public key alone.


Digital Signatures

Signed a document with a GPG key and demonstrated that any tampering immediately invalidates the signature.

Commands:

# Create document
echo "This document is authentic" > document.txt

# Sign the document
gpg --armor --detach-sign document.txt

# Verify original file
gpg --verify document.txt.asc document.txt

# Tamper with the file
echo "tampered" >> document.txt

# Verify tampered file
gpg --verify document.txt.asc document.txt

Results:

State Result
Original file Good signature from "Sedat Yalcin (Fab Futures)"
After tampering BAD signature from "Sedat Yalcin (Fab Futures)"

GPG Key fingerprint:

CE51AD5FB14E020A283D16F740CDDD1055AD7B94

Key takeaways: - A digital signature encrypts the file’s hash with your private key - Anyone with your public key can verify — but only you could have created it - Any change to the file causes verification to fail immediately - Proves both authenticity (who signed it) and integrity (not modified) - Unlike a hash alone, a signature proves identity — not just tampering


File Encryption (Symmetric)

Encrypted a file using AES256 symmetric encryption, then successfully decrypted it.

Commands:

# Create file
echo "This is a secret message" > secret.txt

# Encrypt with AES256
gpg --armor --symmetric --cipher-algo AES256 --batch --passphrase "***" secret.txt

# Decrypt
gpg --batch --passphrase "***" --decrypt secret.txt.asc

Encrypted output (secret.txt.asc):

-----BEGIN PGP MESSAGE-----

jA0ECQMKzOGoXBX4xSv/0lIBS4sCFskoG8FXQIDi/PKI6xCtoaysbOgLd4L3e9Ia
eMySMeLbpRnxDxfgBgEEAFzc+v18503C6BLUROMy/GTEZZC78ZLRmeUeHv4ZOp+a
hA/F
=gQyk
-----END PGP MESSAGE-----

Decryption result:

gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase
This is a secret message

Key takeaways: - AES256 is a symmetric algorithm — same passphrase encrypts and decrypts - The encrypted file is completely unreadable without the passphrase - Symmetric encryption is fast and suitable for large files - The main weakness: how to securely share the passphrase? This is the key distribution problem - Hybrid encryption solves this — use asymmetric (public key) to share the symmetric key, then AES for the data