Skip to content

What Is Encryption? Definition and Examples

Quick answer

Encryption turns readable data into ciphertext that only a key can reverse. A plain definition, how it differs from hashing and encoding, AES and TLS, and a runnable Python example.

What Is Encryption? Definition and Examples

Encryption is the process of transforming readable data into unreadable ciphertext using a key, so only someone with the right key can turn it back. It protects data in transit, such as a login over HTTPS, and data at rest, such as files on a disk or a phone.

Key takeaways

  • Encryption scrambles data with a key; the right key reverses it. Without the key, the data is unreadable.
  • Hashing and encoding are different: hashing is one-way, and encoding is not secret at all.
  • AES is a widely used standard cipher, and TLS is the protocol that secures web traffic.
  • Safe habits matter too: HTTPS for logins, a password manager and two-factor authentication.

On this page:

TermAnalogyReversible?Needs a key?Example use
EncryptionLocked boxYes, with the keyYesProtecting a file or a web session
HashingFingerprint of a fileNo, one-wayNoChecking a file or password match
EncodingBox with a readable labelYes, by anyoneNoBase64 for sending binary data as text
ObfuscationMessy handwritingOften, with effortNoMaking code harder to read

What is encryption?

The NIST glossary gives its first definition as the cryptographic transformation of data to produce ciphertext, citing CNSSI 4009-2022, which takes it from ISO 7498-2:1989. See the NIST glossary entry for encryption.

Plain text goes in, ciphertext comes out. Decryption reverses it with the correct key. The strength rests on the key staying secret, not on hiding how the method works.

How does encryption work, with an example?

A cipher is the method, and a key is the secret input. A toy example is the Caesar shift: move each letter forward by 3, so HELLO becomes KHOOR. It is not secure, because there are only 25 useful shifts to try. Modern systems use ciphers such as AES.

According to NIST FIPS 197 (published 26 November 2001, updated 9 May 2023), three members of the Rijndael family are specified in the Advanced Encryption Standard: AES-128, AES-192 and AES-256, and each transforms data in blocks of 128 bits.

Here is a runnable example with Python's cryptography package (install with pip install cryptography). Its Fernet recipe is built on AES and handles the details for you.

from cryptography.fernet import Fernet

key = Fernet.generate_key()          # keep this key secret
cipher = Fernet(key)

token = cipher.encrypt(b"exam fee receipt: 4521")
print(token)                          # unreadable without the key
print(cipher.decrypt(token).decode()) # exam fee receipt: 4521

The receipt text is invented. If you lose the key, the token cannot be recovered, and anyone who gets the key can read it.

Where is encryption used in daily life?

The most visible place is HTTPS. RFC 8446 (TLS 1.3, August 2018) says TLS allows client and server applications to communicate over the Internet in a way that is designed to prevent eavesdropping, tampering and message forgery. When you open a banking app login page over HTTPS, TLS is what protects that connection. What a particular bank does beyond that connection is set out in its own security pages, not here.

Encryption also protects files on laptops and phones when they are stored, and messages in chat apps that use end-to-end encryption. Check each app's own documentation for exactly what it covers.

Reader checklist.

  • Enter logins only on HTTPS sites, and check the domain.
  • Use a password manager so each account has a different password.
  • Turn on two-factor authentication.

What are the common mistakes and confusions?

  • Mixing up encoding and encryption. Base64 is a format, not protection. Anyone can decode it.
  • Calling hashing encryption. A hash cannot be reversed, so it suits password checks, not storing data you need back.
  • Weak key handling. Hard-coding a key in source code or sharing it in chat defeats the cipher.
  • Inventing your own cipher. Use standard, well-reviewed ones such as AES.
  • Thinking encryption stops phishing. A user tricked into giving a password hands over the key.

Encryption is one tool in the wider field in what cybersecurity is and its types. See how attackers get around it in what phishing is and how access gets limited in what zero trust security is. Developers can read security practices for Spring Boot projects.

Next step

Run the Fernet example, then try changing one character of the token and decrypting again to see it fail. To keep learning, follow the cybersecurity roadmap or try beginner-friendly security tools.

Frequently asked questions

What is encryption in simple words?

Encryption scrambles readable data into ciphertext using a key. Only someone with the right key can unscramble it, so intercepted or stolen data stays unreadable.

What is the difference between encryption and hashing?

Encryption is reversible with the key. Hashing is one-way: it makes a fixed fingerprint of data that cannot be turned back. Hashing suits checking passwords and files, not storing data you need to read later.

What is AES encryption?

AES is the Advanced Encryption Standard, specified by NIST in FIPS 197. It comes in AES-128, AES-192 and AES-256 variants, and each works on data in blocks of 128 bits.

How does HTTPS use encryption?

HTTPS runs HTTP over TLS. According to the IETF, TLS is designed to prevent eavesdropping, tampering and message forgery as client and server applications communicate over the Internet.

Is my data encrypted on WhatsApp or in a banking app?

It depends on the app and what it protects. Check the app's own security documentation instead of assuming. For websites, an https address means the connection uses TLS.

Share LinkedIn X WhatsApp
×

Our Courses

Practice-Based Learning Tracks, Supercharged By A.I.