Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials Computer Science Security Fundamentals
Computer Science Beginner FREE

Security Fundamentals

Lesson 1 of 17 Beginner Interactive

Computer security protects systems and data from unauthorized access, attacks, and damage.

Key Concepts

  • CIA Triad — Confidentiality, Integrity, Availability
  • Authentication — verifying identity
  • Authorization — granting access
  • Encryption — protecting data

Syntax

COMPUTER-SCIENCE
# Hashing (one-way)
import hashlib
hash_obj = hashlib.sha256("password".encode())
print(hash_obj.hexdigest())

# Encryption
from cryptography.fernet import Fernet
key = Fernet.generate_key()
cipher = Fernet(key)
encrypted = cipher.encrypt(b"secret")
Hashing and Encryption
PYTHON
import hashlib

# Password hashing
def hash_password(password):
    return hashlib.sha256(password.encode()).hexdigest()

# Verify password
def verify(password, hashed):
    return hash_password(password) == hashed

password = "mySecret123"
hashed = hash_password(password)
print(f"Password: {password}")
print(f"Hash: {hashed}")
print(f"Verify correct: {verify(password, hashed)}")
print(f"Verify wrong: {verify('wrong', hashed)}")

Practice

1
Exercise

What is the CIA Triad?

Answer
Confidentiality (secrecy), Integrity (accuracy), Availability (access).

Quick Quiz

1

What is encryption?

Encryption converts readable data into unreadable format to protect it.

Interview Questions

Hashing is one-way (can't reverse). Encryption is two-way (can decrypt with key). Hashing for passwords, encryption for data protection.