Please enable JavaScript to use CodeHS

Cybersecurity

What is biometric authentication?

Your phone unlocks when it sees your face or reads your fingerprint. But it isn't storing a photo of you. It's storing a set of numbers, and it's making an educated guess about whether a new scan is close enough to count as a match. Here's how that actually works — and where it can go wrong.

Authentication ~13 min Middle School / High School
The Basics

Three ways to prove who you are

Whenever a computer needs to check that you're really you, it can ask for one of three kinds of evidence. Security people call these authentication factors.

Something you know

A password, a PIN, or the answer to a security question. Anyone who learns it can use it too.

Something you have

A phone that gets a text code, a key card, or a physical security key. You have to physically possess it.

Something you are

Your fingerprint, your face, your voice, even the rhythm of how you type. This is biometric authentication — proving your identity with your body instead of a secret or a device.

Biometrics are convenient because you can't forget your finger at home. But "something you are" behaves very differently from a password, and this tutorial is about exactly how — starting with what your phone is actually doing when it "reads" your fingerprint.


Under The Hood

How fingerprint and face unlock work

Here's the part that surprises most people: your phone does not keep a picture of your finger or your face sitting in storage. Instead, it turns the scan into a short list of numbers called a template — things like the distances between the branch points in your fingerprint's ridges, or the distances between your eyes, nose, and jawline in a face scan.

Setting up biometric unlock

Scan your
finger or face
→
Find key
points
→
Turn them into
a template (numbers)
→
Store the
template

Later, when you try to unlock the device, it repeats the first three steps on your new scan and gets a new template. Then it compares the new template to the stored one. It doesn't check for an exact, pixel-perfect match — it checks how similar the two templates are, using a similarity score.

That's actually really useful. It's why your phone still unlocks if you have a small cut on your finger, if the room is a little darker than usual, or if you're wearing glasses one day and not the next. A small amount of difference is expected, so the system only asks: "Is this close enough?"


Privacy

Why templates matter for privacy

Turning your fingerprint or face into a template isn't just a technical shortcut — it's a privacy safeguard.

Key idea: a biometric template is normally a one-way transformation. Just like you can't turn a smoothie back into whole strawberries, you generally can't reconstruct your actual fingerprint or face from the numbers in a template. And on most modern phones, that template never leaves a special, locked-down chip inside the device — often called a Secure Enclave or a Trusted Execution Environment. It is never sent to the website or app you're logging into. Those apps only ever get a "yes, it matched" or "no, it didn't."

This is different from a password. If a website is hacked and your password leaks, you can change it. Your fingerprint's template for that one device is meant to stay locked inside that device's secure chip, which is exactly why keeping biometric unlock local to your device — instead of uploading raw scans to a server — is considered the safer design.


Accuracy

False accepts and false rejects

No biometric sensor is perfect. Every system has to balance two opposite kinds of mistakes:

  • False accept: the system lets in someone who isn't you. This is a security problem — the wrong person gets access.
  • False reject: the system locks out the real you. This is an annoyance problem — you have to try again or type a backup password.

A very "loose" similarity threshold accepts more near-matches, which cuts down on annoying false rejects but raises the risk of letting an impostor in. A very "strict" threshold does the opposite: fewer false accepts, but more false rejects when your own scan varies slightly. Engineers tune this threshold to balance security and everyday convenience — there's no setting that eliminates both kinds of error at once.


Limits

Where biometrics can go wrong

Biometrics solve some problems that passwords have, but they introduce a few of their own.

  • You can't "reset" a fingerprint. If a password leaks, you pick a new one. You only have ten fingerprints and one face — if a biometric database is compromised, you can't generate a fresh one.
  • Sensors can sometimes be fooled. Researchers have tricked some fingerprint sensors with molded fake prints, and some camera-based face unlock systems with photos or video. Newer sensors fight back with "liveness detection" (checking for things like blood flow, depth, or blinking), but as tools like deepfake video get more convincing, this remains an active arms race — see our tutorial on deepfakes and synthetic media for more on how fake video and audio are made.
  • Biometric data raises unique privacy stakes. Because a face or fingerprint can identify you for life and can't be swapped out, a handful of places (like Illinois' Biometric Information Privacy Act in the United States) place special legal limits on how companies may collect, store, and share biometric data.

None of this means biometrics are unsafe to use day to day — for unlocking your own phone, the convenience and security tradeoff is usually a good one. It just means "something you are" isn't automatically stronger than every other factor; it's a different set of tradeoffs. That's also why many systems pair biometrics with something else, the way a passkey pairs "something you have" (your device) with "something you are" (the unlock that unlocks it).


Code

A tiny matching algorithm

Real fingerprint and face matching systems are complex, but the core idea — compare two templates and check if they're "close enough" — can be shown in a few lines. Here's a simplified version that treats a template as a list of numbers and measures the distance between two templates.

template_match.py
# A stored template is just a list of numbers
# (in real systems: ridge distances, point angles, etc.)
stored_template = [18, 42, 7, 55, 30]

# How "close enough" counts as a match
THRESHOLD = 10.0

def distance(a, b):
    # Bigger distance = less similar templates
    total = 0
    for x, y in zip(a, b):
        total += (x - y) ** 2
    return total ** 0.5

def is_match(new_scan_template):
    d = distance(stored_template, new_scan_template)
    return d <= THRESHOLD

# A new scan that's slightly different, but close
print(is_match([20, 40, 9, 53, 33]))

# A scan from someone else entirely
print(is_match([60, 5, 44, 12, 70]))

Output

True
False

This is only a sketch of the idea — real sensors compare dozens of ridge points or facial measurements, weight them differently, and run extra checks for liveness. But the core logic is the same: measure the distance between two templates and compare it to a threshold.


Interactive

Try it: fingerprint matcher

Below is a simplified stored template — five "minutiae point" values from an enrolled fingerprint. Pick a scan attempt, guess whether you think it will match, then reveal the real similarity score.

Stored template (enrolled fingerprint)

Point A18
Point B42
Point C7
Point D55
Point E30

Step 1. Choose a new scan attempt:

Step 2. Before revealing, guess: match or no match?

0%


Your Turn

Check yourself

1. A friend says, "My phone stores a picture of my thumbprint, so if a hacker breaks in, they'd have a photo of my actual finger." What would you tell them?

Sample answer: Most modern devices don't store an image at all. They store a template — a short list of numbers describing key points of the fingerprint. That template is typically one-way, so it can't be turned back into a picture of the finger, and on most phones it's kept inside a secure chip that never leaves the device.

2. Why can't you just "reset" your fingerprint the way you'd reset a leaked password?

Sample answer: A password is just a secret you chose, so you can pick a new one at any time. A fingerprint is a physical trait tied to your body — you only have ten of them for your whole life, so if one is ever compromised in a way that matters, you can't simply generate a brand-new one the way you can with a password.


Check Yourself

Quick quiz

1. What does a modern phone actually store to recognize your fingerprint or face?

2. Your friend's twin briefly gets waved through your friend's face unlock by mistake. Which kind of error is that?

3. Why can't you simply "reset" a biometric the way you reset a password?

Keep learning

Biometric authentication is one piece of a bigger picture of how modern logins work. Continue the series with What Is Post-Quantum Cryptography?, or go back to What Is a Passkey? to see how "something you are" and "something you have" work together.

An Authentication tutorial from CodeHS, part of the Identity, Login, and Encryption in 2026 series.