📚 A-Level AQA Computer Science: Encryption – Key Revision Points | A-Level AQA 计算机:加密 考点精讲
Encryption is a core topic in AQA A-Level Computer Science, covering the methods used to protect data confidentiality, integrity and authenticity. This guide walks you through symmetric and asymmetric ciphers, classic algorithms like Caesar and Vigenère, the RSA public‑key system, hash functions, digital signatures, and real‑world protocols such as SSL/TLS. Every section pairs an English explanation with a Chinese translation to help you master both the technical vocabulary and the underlying concepts.
加密是 AQA A-Level 计算机科学的核心考点,涉及保护数据机密性、完整性和真实性的方法。本指南将带你梳理对称与非对称密码、凯撒密码和维吉尼亚密码等经典算法、RSA 公钥体系、哈希函数、数字签名以及 SSL/TLS 等真实协议。每节均提供英文说明与中文翻译,帮助你同时掌握技术术语和深层原理。
1. Introduction to Encryption | 加密简介
Encryption is the process of converting readable data (plaintext) into an unreadable form (ciphertext) using an algorithm and a secret key. The primary goal is to ensure confidentiality so that only parties who possess the correct key can reverse the process and recover the original information.
加密是利用算法和密钥将可读数据(明文)转换为不可读形式(密文)的过程。其主要目标是确保机密性,只有拥有正确密钥的一方才能逆转该过程并恢复原始信息。
Modern cryptosystems are built on two broad paradigms: symmetric encryption, where the same key is used for both encryption and decryption, and asymmetric encryption, which uses a mathematically linked key pair – a public key and a private key.
现代密码体系建立在两大范式之上:对称加密(加密和解密使用同一密钥)和非对称加密(使用数学上关联的公钥与私钥对)。
In the AQA specification you are expected to understand how different ciphers work, compare their strengths and weaknesses, and explain why encryption alone is not enough to guarantee security – authentication and integrity matter too.
在 AQA 考试大纲中,你需要理解不同密码的工作原理,比较它们的优缺点,并解释为什么单靠加密不足以保证安全——认证和完整性同样重要。
2. Caesar Cipher | 凯撒密码
The Caesar cipher is one of the simplest substitution ciphers. Each letter in the plaintext is shifted a fixed number of positions down the alphabet. For example, with a shift of 3, ‘A’ becomes ‘D’, ‘B’ becomes ‘E’, and so on. The key is the shift value.
凯撒密码是最简单的替换密码之一。明文中的每个字母在字母表中向后移动固定的位置数。例如,位移为 3 时,’A’ 变成 ‘D’,’B’ 变成 ‘E’,依此类推。密钥即为位移值。
Despite its simplicity, the Caesar cipher introduces several fundamental ideas: the concept of a key, the relationship between plaintext and ciphertext, and the fact that a cipher can be broken by brute force because the key space is tiny (only 25 possible shifts).
尽管很简单,凯撒密码引入了几个基本概念:密钥的概念、明文与密文的关系,以及由于密钥空间极小(只有 25 种可能的位移)导致密码可被暴力破解的事实。
In an exam you might be asked to encrypt or decrypt a short message using a given shift, or to explain why the cipher offers virtually no security in a modern context.
考试中可能要求你使用给定的位移加解密一条短消息,或者解释为什么该密码在现代背景下几乎不提供任何安全性。
3. Vigenère Cipher | 维吉尼亚密码
The Vigenère cipher improves on the Caesar cipher by using a keyword to create a repeating key stream. Each letter of the keyword determines a different Caesar shift for the corresponding plaintext letter. For instance, with the keyword ‘KEY’, the first letter uses a shift of 10 (K), the second a shift of 4 (E), the third a shift of 24 (Y), and the pattern then repeats.
维吉尼亚密码通过使用关键词生成重复的密钥流,改进了凯撒密码。关键词的每个字母为对应的明文字母决定不同的凯撒位移。例如,使用关键词 ‘KEY’ 时,第一个字母位移 10 (K),第二个位移 4 (E),第三个位移 24 (Y),然后该模式重复。
This makes frequency analysis more difficult because the same plaintext letter can be encrypted to different ciphertext letters depending on its position relative to the key. However, if the key is much shorter than the message, patterns still emerge and the cipher can be broken using methods such as Kasiski examination.
这使得频率分析更加困难,因为同一个明文字母可能根据其与密钥的相对位置加密为不同的密文字母。然而,如果密钥远短于消息,仍会出现模式,并且可使用如卡西斯基测试等方法破解该密码。
You need to be able to encrypt and decrypt with a Vigenère square (or by performing the modulo‑26 shift mathematically) and discuss its security limitations.
你需要能够使用维吉尼亚方阵(或通过模 26 的数学位移)进行加解密,并讨论其安全性局限。
4. One-Time Pad | 一次性密码本
The one‑time pad is a symmetric cipher that offers perfect secrecy, provided three stringent conditions are met: the key must be truly random, at least as long as the plaintext, and never reused. Encryption is typically carried out by combining each plaintext character with the corresponding key character using the XOR (⊕) operation.
一次性密码本是一种提供完美保密的对称密码,但必须满足三个严格条件:密钥必须真正随机,长度至少与明文相同,且绝不重复使用。加密通常通过将每个明文字符与对应的密钥字符进行异或 (⊕) 运算来完成。
Decryption uses exactly the same operation: ciphertext ⊕ key = plaintext. Because every possible decryption of a given ciphertext is equally likely without knowledge of the key, the one‑time pad is theoretically unbreakable.
解密使用完全相同的操作:密文 ⊕ 密钥 = 明文。因为在不知道密钥的情况下,给定密文的每一种可能解密结果等概率出现,所以一次性密码本在理论上是不可破解的。
The main practical drawback is key distribution: the sender and receiver must securely exchange a key that is as large as the data to be transmitted, making it impractical for most digital communications.
主要的实际缺陷是密钥分发:发送方和接收方必须安全地交换一个与待传输数据一样大的密钥,这使得它在大多数数字通信中并不实用。
5. Symmetric vs Asymmetric Encryption | 对称与非对称加密
Symmetric encryption uses a single shared key for both encryption and decryption. It is fast and efficient for bulk data, but suffers from the key distribution problem – how do two parties securely agree on the same secret key without an attacker intercepting it?
对称加密使用同一个共享密钥进行加密和解密。它对批量数据速度快、效率高,但存在密钥分发问题——双方如何在不被攻击者截获的情况下安全地商定相同的秘密密钥?
Asymmetric encryption, also called public‑key encryption, uses a pair of mathematically related keys: a public key (shared with everyone) and a private key (kept secret). Anything encrypted with the public key can only be decrypted with the corresponding private key, and vice versa. This solves the key distribution problem but is much slower than symmetric encryption.
非对称加密,也称为公钥加密,使用一对数学上相关的密钥:公钥(向所有人公开)和私钥(保密)。任何用公钥加密的数据只能用对应的私钥解密,反之亦然。这解决了密钥分发问题,但速度比对称加密慢得多。
| Feature | Symmetric | Asymmetric |
|---|---|---|
| Keys | One shared key | Public & private key pair |
| Speed | Fast | Slow (100–1000 times slower) |
| Key distribution | Difficult – secure channel needed | Easy – public key can be shared openly |
| Common algorithms | AES, DES, 3DES | RSA, ECC |
| Use cases | Bulk data encryption (e.g. file storage) | Key exchange, digital signatures |
In practice, secure systems combine both: asymmetric encryption is used during a handshake to safely exchange a temporary symmetric session key, after which the faster symmetric encryption takes over.
实际中,安全系统将二者结合:在握手阶段使用非对称加密安全地交换一个临时的对称会话密钥,之后由更快的对称加密接手通信。
6. RSA Algorithm Overview | RSA 算法概述
RSA is the most widely taught public‑key algorithm in the AQA specification. Its security relies on the computational difficulty of factorising the product of two large prime numbers. Key generation proceeds as follows:
RSA 是 AQA 考试大纲中讲授最广泛的公钥算法。其安全性依赖于分解两个大素数乘积的计算困难性。密钥生成过程如下:
Choose two large primes p and q. Compute n = p × q and Euler’s totient φ(n) = (p‑1)(q‑1). Select a public exponent e such that 1 < e < φ(n) and e is coprime to φ(n). Then calculate the private exponent d, the modular multiplicative inverse of e modulo φ(n), satisfying (d × e) mod φ(n) = 1.
选择两个大素数 p 和 q。计算 n = p × q 以及欧拉函数 φ(n) = (p‑1)(q‑1)。选择一个公钥指数 e,满足 1 < e < φ(n) 且 e 与 φ(n) 互质。然后计算私钥指数 d,它是 e 模 φ(n) 的模逆元,满足 (d × e) mod φ(n) = 1。
The public key is the pair (e, n); the private key is (d, n). Encryption turns a plaintext message m into ciphertext c using:
公钥为 (e, n);私钥为 (d, n)。加密将明文消息 m 转换为密文 c,使用:
c = mᵉ mod n
Decryption recovers the plaintext with:
解密恢复明文,使用:
m = cᵈ mod n
A tiny textbook example: p = 3, q = 11 → n = 33, φ(n) = 20. Choose e = 7, then d = 3 because 7 × 3 = 21 ≡ 1 mod 20. Encrypt m = 4: c = 4⁷ mod 33 = 16384 mod 33 = 16. Decrypt c = 16: m = 16³ mod 33 = 4096 mod 33 = 4.
一个小型教科书示例:p = 3, q = 11 → n = 33, φ(n) = 20。选择 e = 7,则 d = 3,因为 7 × 3 = 21 ≡ 1 mod 20。加密 m = 4:c = 4⁷ mod 33 = 16384 mod 33 = 16。解密 c = 16:m = 16³ mod 33 = 4096 mod 33 = 4。
In an exam you may be asked to perform simple modular arithmetic, explain why the scheme is secure, or discuss the practical issue that RSA is too slow for bulk data and is therefore used primarily to encrypt symmetric keys.
考试中可能要求你进行简单的模运算,解释该方案为何安全,或讨论 RSA 对批量数据太慢因此主要用于加密对称密钥的实际问题。
7. Hash Functions | 哈希函数
A hash function takes an input (or message) and returns a fixed‑size string of bytes. The output, often called a digest, is unique to the given input: even a tiny change in the input produces a wildly different hash. Cryptographic hash functions must be one‑way (pre‑image resistant) and collision‑resistant – meaning it is infeasible to find two different inputs that produce the same hash.
哈希函数接受输入(或消息)并返回一个固定大小的字节串。其输出通常称为摘要,对给定输入是唯一的:即使输入发生微小变化,也会产生截然不同的哈希值。密码学哈希函数必须是单向的(抗原像)且抗碰撞的——即找不到两个不同输入产生相同哈希值。
Common examples are SHA‑256 and the older MD5 (which is no longer considered secure due to collision vulnerabilities). Hash functions are used to verify data integrity, to store passwords securely (storing the hash instead of the plaintext password), and as building blocks in digital signatures.
常见的例子包括 SHA‑256 和较早的 MD5(由于碰撞漏洞,MD5 已被认为不安全)。哈希函数用于验证数据完整性、安全存储密码(存储哈希值而非明文密码),以及作为数字签名的构建模块。
8. Digital Signatures | 数字签名
A digital signature provides three critical security properties: authentication (the message truly comes from the claimed sender), non‑repudiation (the sender cannot deny having sent the message), and integrity (the message has not been altered). The process typically works as follows:
数字签名提供三项关键的安全属性:认证(消息确实来自声称的发送者)、不可否认性(发送者无法否认发送过消息)以及完整性(消息未被篡改)。通常的过程如下:
The sender generates a hash of the message and then encrypts this hash with their private key. The resulting encrypted hash is the digital signature, which is appended to the message. The recipient decrypts the signature using the sender’s public key, recomputes the hash of the received message, and compares the two. If they match, the signature is valid.
发送者生成消息的哈希,然后用其私钥加密该哈希。生成的加密哈希即为数字签名,附加在消息上。接收者使用发送者的公钥解密签名,重新计算收到消息的哈希,并比较两者。若匹配,则签名有效。
It is important to note that a digital signature does not encrypt the message itself; it only protects the message’s integrity and origin. The most common exam pitfall is confusing digital signatures with encryption – a signature proves who sent a message, while encryption hides the message content.
必须注意,数字签名并不加密消息本身;它只保护消息的完整性和来源。考试中最常见的陷阱是将数字签名与加密混淆——签名证明谁发送了消息,而加密隐藏消息内容。
9. Man-in-the-Middle Attack | 中间人攻击
A man‑in‑the‑middle (MitM) attack occurs when an adversary secretly intercepts and possibly alters the communication between two parties who believe they are talking directly to each other. In a key‑exchange scenario, the attacker could intercept the public keys and substitute them with their own, allowing them to decrypt and re‑encrypt all traffic unnoticed.
当攻击者秘密截获并可能篡改两方之间的通信,而双方以为在直接对话时,就发生了中间人攻击。在密钥交换场景中,攻击者可以截获公钥并用自己生成的公钥替换,从而在双方毫无察觉的情况下解密并重新加密所有流量。
This vulnerability highlights that asymmetric encryption alone cannot guarantee secure communication unless the public keys are authenticated. That is where certificates and certificate authorities (CAs) become essential.
这一漏洞凸显出,除非公钥得到认证,否则非对称加密本身无法保证安全通信。这正是证书和证书颁发机构 (CA) 变得至关重要的原因。
10. SSL/TLS and Secure Communication | SSL/TLS 与安全通信
Transport Layer Security (TLS), and its predecessor SSL, is the protocol that underpins secure web browsing (HTTPS). It combines symmetric and asymmetric cryptography to provide confidentiality, integrity and authentication for data transmitted over a network.
传输层安全协议 (TLS) 及其前身 SSL,是支撑安全网页浏览 (HTTPS) 的协议。它结合对称与非对称密码学,为网络上传输的数据提供机密性、完整性和认证。
The TLS handshake begins with the client and server agreeing on cipher suites, then the server sends its digital certificate containing its public key. The certificate is signed by a trusted Certificate Authority, so the client can verify the server’s identity. They then use the server’s public key to securely exchange a random symmetric session key, which is used for the remainder of the session to encrypt data efficiently.
TLS 握手从客户端与服务器协商密码套件开始,随后服务器发送包含其公钥的数字证书。该证书由受信任的证书颁发机构签名,因此客户端可以验证服务器的身份。然后它们使用服务器的公钥安全地交换一个随机的对称会话密钥,该密钥会在会话剩余时间内高效加密数据。
This hybrid approach gives us the speed of symmetric encryption without the key‑distribution headache, and the authentication strength of asymmetric encryption, all bound together by the trust chain rooted in CAs.
这种混合方法让我们同时获得对称加密的速度(而无需费力分发密钥)与非对称加密的认证强度,并通过根植于 CA 的信任链将所有部分绑定在一起。
11. Exam Tips and Common Mistakes | 考试技巧与常见错误
Make sure you can clearly distinguish between encryption (hiding data) and hashing (creating a fixed‑size fingerprint). Do not describe a hash as ‘encrypted’ or a signature as ‘hashing with a private key’ – precise terminology is crucial in A‑Level marking schemes.
务必能清楚区分加密(隐藏数据)与哈希(生成固定大小的指纹)。不要将哈希描述为“加密”,或将签名描述为“用私钥作哈希”——在 A‑Level 评分方案中,术语的准确性至关重要。
When working with RSA, always show your modular arithmetic step by step. If the numbers are large, simplify the exponentiations using repeated squaring or by reducing intermediate results modulo n. Remember that the private key d is derived from e and φ(n), not simply from n alone.
在处理 RSA 时,务必逐步展示模运算过程。若数字较大,可使用重复平方法或中间结果模 n 化简来简化指数运算。记住私钥 d 是根据 e 和 φ(n) 推导出来的,而不仅仅与 n 有关。
For the one‑time pad, emphasise all three requirements: randomness, length, and non‑reuse. If any one of them is violated the cipher loses its perfect secrecy. In comparisons, always tie strengths and weaknesses to concrete factors such as key length, speed, and key‑distribution challenges.
对于一次性密码本,要强调全部三个要求:随机性、长度和不重用。若违反任何一条,密码就会丧失其完美保密性。在进行对比时,始终将优缺点与具体因素相联系,如密钥长度、速度和密钥分发挑战。
Avoid stating that a digital signature encrypts the whole message – it does not. Also, be prepared to explain why SSL/TLS uses both types of encryption, not just asymmetric, and how a certificate prevents a man‑in‑the‑middle attack.
避免声称数字签名会加密整个消息——它不会。此外,准备好解释 SSL/TLS 为何同时使用两种加密而不是仅用非对称加密,以及证书如何防止中间人攻击。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导