Encryption and hashing
| English | Chinese | Pinyin |
|---|---|---|
| encryption | 加密 | jiā mì |
| plaintext | 明文 | míng wén |
| ciphertext | 密文 | mì wén |
| decrypt | 解密 | jiě mì |
| symmetric | 对称 | duì chèn |
| asymmetric | 非对称 | fēi duì chèn |
| digest | 摘要 | zhāi yào |
| private key | 私钥 | sī yào |
| public key | 公钥 | gōng yào |
| key pair | 密钥对 | mì yào duì |
| session key | 会话密钥 | huì huà mì yào |
| cryptographic hash | 密码散列 | mì mǎ sàn liè |
Keeping secrets safe
- Encryption 加密 turns readable plaintext 明文 into unreadable ciphertext 密文 using a key.
- Only someone with the right key can decrypt 解密 it back.
- There are two families — symmetric 对称 and asymmetric 非对称 — plus one-way hashing.
Symmetric encryption
- Symmetric encryption uses the same key for encrypting and decrypting.
- It is fast and ideal for bulk data (a whole disk, a video stream).
- Its weakness is key distribution — how do you share the secret key safely in the first place?

Signing hashes the message and encrypts the digest 摘要 with the private key 私钥; the receiver checks it with the public key 公钥
A shift cipher (symmetric key)
Caesar's cipher shifts every letter forward by a fixed key. The SAME key both encrypts and decrypts — that is what symmetric means. Try to read the ciphertext without knowing the shift.
Symmetric encryption uses:
Symmetric encryption shares one secret key — fast, but it must be distributed securely.
Asymmetric encryption
- Each user has a key pair 密钥对: a public key they publish and a private key they keep secret.
- Data encrypted with the public key can be decrypted only with the matching private key.
- To message Alice: encrypt with her public key; only she can decrypt. No prior key exchange needed — but it is much slower, so not used for large data.

A hardware security key stores a secret key to prove who you are
Match each cryptographic tool to what it uses.
Symmetric is fast but needs key sharing; asymmetric solves that with a key pair; hashing is one-way; HTTPS combines them.
To send a confidential message to Alice using asymmetric encryption, you encrypt with:
Encrypting with the recipient's public key means only their matching private key can decrypt it.
Hybrid approach (what real systems use)
- Use asymmetric to exchange a fresh session key 会话密钥, then use that symmetric key for the data:
- the client makes a random session key → encrypts it with the server's public key → the server decrypts it with its private key → both now share it for fast symmetric encryption.
- This is how HTTPS and SSH work.

The Enigma machine encrypted messages in the Second World War — an early cipher device.
In the hybrid approach used by HTTPS, asymmetric encryption is used to:
Slow asymmetric crypto just shares a session key; the bulk data then uses fast symmetric encryption.
Hashing (one-way)
- A cryptographic hash 密码散列 turns any input into a fixed-size digest; the same input always gives the same digest, and a tiny change alters it completely.
- It is one-way — you cannot recover the input.
- Used for password checks, integrity checks and digital signatures. (Hashing is not encryption — there's no key to reverse it.)

Encryption scrambles plaintext with a key; decryption reverses it
- Also know: symmetric key cryptography vs asymmetric key cryptography turn plain text into cipher text; Secure Socket Layer (SSL) / Transport Layer Security (TLS) secure web traffic with digital certification; quantum cryptography is an emerging method.
Hashing and the avalanche effect
A hash is one-way: easy to compute, practically impossible to reverse. A tiny change in the input flips a large, unpredictable part of the output — the avalanche effect that makes hashes good for passwords.
A cryptographic hash is one-way (you cannot recover the input from the digest) and shows the avalanche effect — a tiny change in the input flips a large, unpredictable part of the output.
One-wayness plus avalanche is what makes hashes good for storing passwords and checking integrity.
You've got it
- symmetric = one shared key (fast, bulk) but has the key-distribution problem
- asymmetric = public/private key pair (solves key sharing) but slow
- hybrid: swap a session key with asymmetric, then use symmetric (HTTPS/SSH)
- hashing = one-way digest (no key); for integrity and password checks