Find a course

Module 5: Networks, Security and SocietyLesson 12 of 1214 min

Security, AI and Computing Ethics

See how encryption, hashing and strong passwords protect data, get a plain introduction to machine learning, and weigh the ethics of computing.

Step 1 of 16Learn

Secrets on a public network

Every time you log in, pay online or send a private message, your data crosses networks owned by strangers. Anyone along the path could, in principle, copy the packets. Security doesn't depend on hiding the packets; it depends on making them useless to anyone without the right key. That's encryption.

Encryption uses a mathematical algorithm and a key to turn readable data (plaintext) into scrambled data (ciphertext). Only someone with the right key can reverse it.

There are two main kinds:

  • Symmetric encryption uses the same key to encrypt and decrypt. It's fast, so it's used for the bulk of data, but both sides need the key, and sending it safely is the hard part.
  • Public-key (asymmetric) encryption uses a pair of keys. The public key can be shared with anyone and is used to encrypt; only the matching private key can decrypt. It's like a mailbox with a slot: anyone can drop a letter in, but only the owner can open it.

HTTPS combines both. Public-key methods let your browser and the server agree on a fresh shared secret without ever sending it in the open; then fast symmetric encryption protects the actual data.

Modern encryption is strong enough that breaking it by trying every key would take longer than the age of the universe. Real attacks usually target people instead: stolen passwords, phishing and unpatched software.

Step 2 of 16Practice · Choose one

In public-key encryption, Ana wants to send Ben a secret message. Which key should she use to encrypt it?

Step 3 of 16Diagram

Ana sends Ben a secret

Ana sends Ben a secretProcess diagram: Ben shares his public key → Ana encrypts with it → Ciphertext crosses the internet → Ben decrypts with his private key.Ben shareshis public keyAna encryptswith itCiphertextcrosses theinternetBen decryptswith hisprivate key

Tap a shape with to see more.

Ben shares his public key

Anyone may see it.

Ana encrypts with it
Ciphertext crosses the internet

Eavesdroppers see only scrambled data.

Ben decrypts with his private key

Only he has it.

Step 4 of 16Learn

Hashing and how passwords are stored

A well-run website never stores your actual password. It stores a hash of it.

A hash function takes any input and produces a fixed-size output, a kind of fingerprint. Good cryptographic hash functions have three key properties:

  1. Deterministic: the same input always gives the same hash.
  2. One-way: given a hash, it's practically impossible to work back to the input.
  3. Avalanche effect: changing one character of the input changes the hash completely.

When you create an account, the site hashes your password and stores the hash. When you log in, it hashes what you typed and compares the two hashes. If a hacker steals the database, they get hashes, not passwords.

Attackers respond by guessing: they hash billions of common passwords and look for matches. Sites defend with salting (adding a random value to each password before hashing, so identical passwords produce different hashes) and with deliberately slow hash functions designed for passwords, so each guess costs more.

Hashes have other uses too: checking that a downloaded file wasn't corrupted or tampered with, detecting duplicate files, and linking the blocks in a blockchain.

Step 5 of 16Practice · Sort into groups

Sort each statement: is it a property of a good cryptographic hash function, or not?

Tap an item, then tap its group (or drag it there).

Step 6 of 16Diagram

Checking a password without storing it

Checking a password without storing itProcess diagram: You type a password → Add the stored salt → Hash it → Compare with the stored hash.You type apasswordAdd thestored saltHash itComparewith thestored hash

Tap a shape with to see more.

You type a password
Add the stored salt

A random value per user, so identical passwords hash differently.

Hash it

A slow, purpose-built password hash makes guessing expensive.

Compare with the stored hash

Match: you are in. The site never needed your actual password.

Step 7 of 16Try the calculator

Password strength estimator

Estimate how long it would take to try every possible password at a given guessing speed. Real attackers try common passwords first, so a predictable password falls much faster than these numbers suggest.

Entropy (bits)
47.6 bits
Hours to try every combination
6.1 hours
Years to try every combination
0 years

Step 8 of 16Practice · Estimate

Use the estimator with 62 possible characters and 10 billion guesses per second. Roughly how many hours does it take to try every 8-character password?

15 hours

Step 9 of 16Learn

Machine learning in plain terms

Traditional programs follow rules a human wrote: "IF the email contains these words, mark it as spam." But some tasks are hard to describe with rules. How would you write rules to recognize a cat in a photo, or to translate a joke?

Machine learning (ML) takes a different approach. Instead of writing the rules, you give a program many examples and let it find patterns. Show a model millions of emails labeled "spam" or "not spam," and it adjusts millions of internal numbers (parameters) until it can label new emails it has never seen. This is called training.

A few key ideas:

  • Training data shapes everything. A model learns whatever patterns exist in its data, including errors and biases.
  • Generalization is the goal: performing well on new examples, not just memorizing the training set.
  • Neural networks, loosely inspired by the brain, are layers of simple math units. Very large ones, trained on vast amounts of text, power today's chatbots, which generate replies by predicting likely next words.

ML systems can be impressive and still fail in surprising ways. A model that classifies skin conditions might perform worse on skin tones that were rare in its training data. Understanding where the data came from is as important as understanding the algorithm.

Step 10 of 16Compare

Traditional programming vs machine learning

AspectTraditional programMachine learning
Human providesThe rulesExamples with answers (data)
Computer producesAnswers from the rulesA model that captures patterns
Good forClear, stable logic like tax rulesFuzzy patterns like images, speech, spam
Main riskRules miss casesLearns the biases and gaps in its data

Step 11 of 16Note

Step 12 of 16Practice · True or false

A machine learning model trained on biased data can produce biased results even if its algorithm contains no unfair rules.

Step 13 of 16Note

Step 14 of 16Learn

Ethics: just because we can

Computing gives individuals and organizations enormous power, so computer scientists increasingly ask not only "can we build it?" but "should we, and how?" A few recurring questions:

Privacy. Apps can collect location, contacts, browsing habits and more. Combined, these reveal intimate details. Who owns that data? Laws such as the EU's GDPR give people rights over their data, but rules differ by country, and much depends on how products are designed.

Fairness and bias. Algorithms now help decide who gets a loan, a job interview or extra police attention. If they're trained on biased historical data, they can quietly scale up unfairness. Testing systems on different groups and keeping humans accountable for decisions are key safeguards.

Security and responsibility. Software bugs can leak millions of records or, in medical devices and cars, cause physical harm. Professional codes of ethics, like those of the ACM, ask computing professionals to avoid harm and to be honest about the limits of their systems.

Access and environment. Not everyone has fast internet or a modern device, and large data centers use significant energy and water.

There are rarely easy answers, but the habit of asking who benefits, who might be harmed and who is accountable is part of being a good computer scientist.

Step 15 of 16Practice · What would you do?

What would you do?

A school district wants to use an algorithm to predict which students are likely to drop out, so counselors can offer help early. It was trained on ten years of the district's records. What should they do before relying on it?

Step 16 of 16Practice · Choose one

Why do security experts say a long passphrase like "correct-river-lamp-cactus" can be stronger than "Tr0ub!e"?