Courses / Computer Science XII (HSSC-II) – FBISE Complete SLO-Based Course

6.2 Security Methods: 2FA, Biometrics, Cryptography and Secure Transmission

Unit 6 – Impacts of Computing · 90 min read · 10 MCQs to check yourself

Two-factor authentication explained for beginners

What is asymmetric vs symmetric encryption?

1. Authentication factors

Factor Examples
Something you know password, PIN, security question
Something you have phone receiving an OTP, authenticator app, smart card, hardware key
Something you are (biometric) fingerprint, face, iris, voice

2FA / MFA combines two or more different factors. A stolen password alone is useless without the phone or fingerprint.

2. Biometric verification

A sensor captures a trait (fingerprint, face), converts it into a mathematical template, and compares it with the stored template. NADRA uses biometric verification for SIM issuance and bank accounts in Pakistan.

Advantages Disadvantages
Cannot be forgotten or easily shared Cannot be changed if the template is stolen
Fast and convenient (one touch) Privacy concerns if stored centrally
Hard to guess False matches/rejections (cuts, dirty fingers, poor light)
Proves the person is present Costly sensors; some disabled users may not be able to use them

Best practice: store biometric templates encrypted on the device (secure chip), not in a central database, and combine with another factor.

3. Cryptography basics

Cryptography keeps data secret and trustworthy:

Classic ciphers

Caesar cipher – shift each letter by a fixed number (key = 3: A→D, B→E).

def caesar(text, shift):
    result = ""
    for ch in text.upper():
        if ch.isalpha():
            result += chr((ord(ch) - 65 + shift) % 26 + 65)
        else:
            result += ch
    return result

secret = caesar("MEET AT NOON", 3)
print(secret)
print(caesar(secret, -3))

Output:

PHHW DW QRRQ
MEET AT NOON

With only 25 possible keys it is broken instantly by brute force – try every shift.

Vigenère cipher – uses a keyword; each letter is shifted by a different amount (key “KEY”: shifts 10, 4, 24, …), so the same plaintext letter can become different ciphertext letters.

def vigenere(text, key, decrypt=False):
    out, k = "", 0
    for ch in text.upper():
        if ch.isalpha():
            shift = ord(key[k % len(key)].upper()) - 65
            if decrypt:
                shift = -shift
            out += chr((ord(ch) - 65 + shift) % 26 + 65)
            k += 1
        else:
            out += ch
    return out

c = vigenere("ATTACK AT DAWN", "LEMON")
print(c, "->", vigenere(c, "LEMON", decrypt=True))

Output:

LXFOPV EF RNHR -> ATTACK AT DAWN

Modern encryption

Symmetric (e.g. AES) Asymmetric (e.g. RSA, ECC)
Keys one shared secret key public key (share freely) + private key (keep secret)
Speed very fast – good for large data slower
Problem how to share the key safely slower, larger keys
Use encrypting files, disks, Wi-Fi (WPA2/WPA3), the data in HTTPS key exchange, digital signatures, HTTPS handshake

Hashing (SHA-256) turns data into a fixed-length fingerprint that cannot be reversed – used to store passwords (with a random salt) and check integrity of downloads.

import hashlib
print(hashlib.sha256(b"password123").hexdigest()[:32], "...")
print(hashlib.sha256(b"password124").hexdigest()[:32], "...")

Output:

ef92b778bafe771e89245b89ecbc08a4 ...
33631376724e5d5480fa397dfcf03b66 ...

A tiny change in input gives a completely different hash.

4. Secure transmission of data

5. Applying security to apps you create

Hash passwords (never store plain text) · use HTTPS · validate input and use parameterised SQL (no injection) · add 2FA for admin accounts · least-privilege database users · keep libraries updated · log and monitor logins.

6. Evaluating protocols in devices

System Protocols/methods used Evaluation
Mobile banking app TLS, OTP/biometric 2FA, device binding Strong if users never share OTPs
Home Wi-Fi router WPA2/WPA3, admin password Weak if default password or old WEP is used
WhatsApp End-to-end encryption, optional 2-step PIN Strong for messages; backups must also be encrypted
Website login over HTTP none Insecure – credentials visible on the network

Short and long questions

1. Why are security methods important for protecting data? Explain the role of the following methods in securing information and preventing identity theft: (a) Biometric verification (b) Cryptography. (2 + 4)

Model answer

Importance (2): security methods protect the confidentiality, integrity and availability of data; prevent fraud, unauthorised access and identity theft; ensure legal compliance (PECA 2016, banking rules); and maintain user and customer trust in digital services.

(a) Biometric verification (2): a sensor captures a physical trait (fingerprint, face, iris), converts it into a template and compares it with the enrolled template. Because the trait belongs only to the real person, a criminal with stolen passwords or CNIC copies cannot impersonate the owner – e.g. NADRA biometric verification before issuing a SIM or opening a bank account, fingerprint login to banking apps. Templates should be encrypted and stored on the device, and biometrics combined with another factor because they cannot be changed if leaked.

(b) Cryptography (2): encryption turns data into ciphertext so stolen data is useless without the key. In transmission, HTTPS/TLS and end-to-end encryption stop eavesdroppers capturing passwords or OTPs on public Wi-Fi. In storage, AES-encrypted databases and disks protect personal records if a laptop or server is stolen, and passwords are stored as salted hashes. Digital signatures (asymmetric keys) prove that messages and documents really come from the claimed sender, preventing forged identities.

2. How does HTTPS secure data transmitted between a browser and a website?

Model answer
  1. The server sends a digital certificate proving its identity (checked by the browser).
  2. Browser and server use asymmetric encryption to agree a shared session key securely.
  3. All data is then encrypted with fast symmetric encryption (TLS), so passwords and card numbers cannot be read or changed by anyone on the network (e.g. public Wi-Fi).

3. What are the advantages and limitations of biometric verification?

Model answer

Advantages: unique to each person; cannot be forgotten or easily shared; fast and convenient; proves the person is present (NADRA SIM verification). Limitations: cannot be changed if the template leaks; privacy risks if stored centrally; false accepts/rejects; sensors cost money and some people (injuries, disabilities) cannot use them.

4. Differentiate between symmetric and asymmetric encryption.

Model answer
Symmetric Asymmetric
One shared secret key for encryption and decryption Key pair: public key encrypts, private key decrypts
Fast; suitable for large data Slower; used for key exchange and digital signatures
Key distribution is the main problem No need to share the private key
Example: AES Example: RSA

5. Encrypt "PAKISTAN" using a Caesar cipher with a shift of 4.

Model answer

P→T, A→E, K→O, I→M, S→W, T→X, A→E, N→R Ciphertext: TEOMWXER

6. Explain two-factor authentication with an example. Why is it more secure than a password alone?

Model answer

2FA requires two different types of evidence: something you know (password), have (phone/OTP/app) or are (fingerprint). Example: logging into a bank app with a password and then entering an OTP sent by SMS or approving with a fingerprint. It is more secure because a stolen or guessed password alone is not enough; the attacker also needs the user’s phone or fingerprint.

7. What is the purpose of cryptography in data security? Enlist any two commonly used ciphers. (1 + 2)

Model answer

Purpose (1): cryptography converts readable data (plaintext) into unreadable ciphertext so that only authorised people with the key can read it – ensuring confidentiality, and with hashing/signatures, integrity and authentication – during storage and transmission. Ciphers (2): e.g. Caesar cipher (shift letters), Vigenère cipher (keyword shifts), AES (modern symmetric), RSA (asymmetric public-key).

This lesson ends with a quiz of 10 MCQs. Open the lesson on PrepOasis to take it and save your progress.

Previous: 6.1 Safe Collaboration Online and Common Cyber Attacks · Next: 6.3 Equity and Equal Access to Information: Bridging the Digital Divide

All lessons in Computer Science XII (HSSC-II) – FBISE Complete SLO-Based Course