📚 IB Computer Science: Encryption Revision | IB 计算机:加密 考点精讲
Encryption is a fundamental concept in IB Computer Science, appearing across the core syllabus under network security, data protection, and the ethical use of information. This revision guide covers symmetric and asymmetric encryption, key algorithms such as Caesar and RSA, hashing, digital signatures, certificates, and SSL/TLS. Understanding how plaintext is transformed into ciphertext and how keys are managed is essential for both Paper 1 and Paper 2 responses, as well as for the internal assessment where data security might be considered.
加密是 IB 计算机科学中的一个基础概念,出现在核心大纲的网络安全、数据保护以及信息伦理使用等部分。本复习指南涵盖对称加密与非对称加密、凯撒密码和 RSA 等关键算法、哈希、数字签名、数字证书和 SSL/TLS。理解明文如何转换为密文以及密钥如何管理,对 Paper 1 和 Paper 2 的答题都非常重要,在内部评估中若涉及数据安全也需要用到这些知识。
1. What is Encryption? | 什么是加密?
Encryption is the process of converting readable data (plaintext) into an unreadable format (ciphertext) using an algorithm and a key. The purpose is to ensure confidentiality, so that only authorised parties with the correct key can decrypt the message and recover the original plaintext. In IB terms, encryption is a key countermeasure against data interception, eavesdropping, and unauthorised access in networks.
加密是通过算法和密钥将可读数据(明文)转换为不可读格式(密文)的过程。其目的是确保机密性,只有拥有正确密钥的授权方才能解密密文并恢复原始明文。在 IB 语境中,加密是针对网络中的数据拦截、窃听和未经授权访问的关键对策。
The two main families of encryption are symmetric encryption, where the same key is used for encryption and decryption, and asymmetric encryption, which uses a pair of mathematically related keys – a public key and a private key. Cryptographic systems often combine both to balance efficiency and security, such as in hybrid encryption used by HTTPS.
加密的两大分支是对称加密(使用同一密钥进行加解密)和非对称加密(使用一对数学相关的密钥——公钥和私钥)。密码系统通常会结合两者以平衡效率与安全,例如 HTTPS 中使用的混合加密。
2. Symmetric Encryption | 对称加密
Symmetric encryption uses a single secret key that must be shared between the sender and receiver. It is fast and efficient, making it suitable for encrypting large volumes of data. Common symmetric algorithms include AES (Advanced Encryption Standard) and DES (Data Encryption Standard), though DES is now considered insecure due to its small key size. In IB Computer Science, you need to be able to explain how symmetric encryption works and to identify its main drawback: the key distribution problem. If the key is intercepted during transmission, the entire security is compromised.
对称加密使用单一的密钥,必须在发送方和接收方之间共享。它速度快、效率高,适用于加密大量数据。常见的对称算法包括 AES(高级加密标准)和 DES(数据加密标准),不过 DES 由于密钥长度较小现在已被认为不安全。在 IB 计算机科学中,你需要能解释对称加密的工作原理,并指出其主要缺点:密钥分发问题。如果密钥在传输过程中被截获,整个安全体系就会遭到破坏。
To understand the key distribution challenge, imagine two parties who have never met and have no secure channel. They cannot simply send the secret key over the network, because an attacker could intercept it. Solutions such as the Diffie-Hellman key exchange or the use of asymmetric encryption to wrap the symmetric key are typically employed in real-world protocols.
要理解密钥分发的挑战,可以想象两个从未见过面且没有安全信道的通信方。他们不能简单地在网络上发送密钥,因为攻击者可能截获它。现实协议中通常采用 Diffie-Hellman 密钥交换或利用非对称加密来封装对称密钥等解决方案。
3. Caesar Cipher: A Classic Example | 凯撒密码:一个经典示例
The Caesar cipher is a substitution cipher where each letter in the plaintext is shifted by a fixed number of places down the alphabet. For example, with a shift of 3, ‘A’ becomes ‘D’, ‘B’ becomes ‘E’, and so on. Although trivial to break by brute force (only 25 possible keys), it illustrates the core concepts of plaintext, ciphertext, key, and algorithm, which are important for Paper 1 definitions.
凯撒密码是一种替换密码,明文中的每个字母都按照字母表向后移动固定位数。例如,移位 3 时,’A’ 变为 ‘D’,’B’ 变为 ‘E’,依此类推。虽然由于只有 25 种可能的密钥,通过暴力破解很容易攻破,但它清晰地说明了明文、密文、密钥和算法这些核心概念,这些对 Paper 1 中的定义题很重要。
To represent the encryption mathematically: let x be the position of the plaintext letter (A=0, B=1, …, Z=25), k be the shift key, and c be the ciphertext position. Then c = (x + k) mod 26. Decryption is simply x = (c − k) mod 26. In IB, you may be asked to encrypt or decrypt a short message using a given shift, or to comment on why the Caesar cipher is not secure by modern standards.
用数学表示为:设 x 为明文字母的位置(A=0, B=1, …, Z=25),k 为移位密钥,c 为密文位置。则 c = (x + k) mod 26。解密为 x = (c − k) mod 26。在 IB 考试中,你可能会被要求用给定的移位值加密或解密一段简短信息,或者评论为何凯撒密码按现代标准已不安全。
4. Asymmetric Encryption | 非对称加密
Asymmetric encryption, also known as public-key cryptography, uses two keys: a public key that can be freely distributed and a private key that must remain secret. Whatever is encrypted with the public key can only be decrypted by the corresponding private key, and vice versa. This solves the key distribution problem because no shared secret needs to be transmitted beforehand. RSA and ECC (Elliptic Curve Cryptography) are widely used asymmetric algorithms.
非对称加密也称为公钥密码,使用两个密钥:可自由分发的公钥和必须保密的私钥。用公钥加密的内容只能用对应的私钥解密,反之亦然。这解决了密钥分发问题,因为无需事先传输共享秘密。RSA 和 ECC(椭圆曲线密码学)是广泛使用的非对称算法。
In IB, you need to be able to compare symmetric and asymmetric encryption. While symmetric encryption is faster and suited for bulk data, asymmetric encryption provides a secure method for key exchange and digital signatures. A typical scenario is that a client uses the server’s public key to encrypt a random symmetric key, which is then used for the rest of the session. This hybrid approach leverages the strengths of both systems.
在 IB 中,你需要能够比较对称与非对称加密。对称加密速度较快,适合加密大量数据,而非对称加密则为密钥交换和数字签名提供了安全的方式。一个典型的场景是,客户端使用服务器的公钥加密一个随机对称密钥,接下来会话就使用这个对称密钥。这种混合方法发挥了两者的优势。
5. The RSA Algorithm | RSA 算法
RSA is one of the first public-key cryptosystems and is widely described in IB courses. It relies on the mathematical difficulty of factoring the product of two large prime numbers. The key generation, encryption, and decryption steps can be summarised as follows. Choose two distinct large primes p and q; compute n = p × q and φ(n) = (p-1)(q-1). Choose an integer e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1. Compute the private exponent d such that d × e ≡ 1 (mod φ(n)). The public key is (n, e) and the private key is (n, d). Encryption: ciphertext c = mᵉ mod n. Decryption: plaintext m = cᵈ mod n.
RSA 是最早的公钥密码系统之一,在 IB 课程中被广泛介绍。它依赖大整数分解质因数的数学困难性。密钥生成、加密和解密的步骤可概括如下。选择两个不同的大质数 p 和 q;计算 n = p × q 和 φ(n) = (p-1)(q-1)。选择一个整数 e 满足 1 < e < φ(n) 且 gcd(e, φ(n)) = 1。计算私有指数 d 使 d × e ≡ 1 (mod φ(n))。公钥是 (n, e),私钥是 (n, d)。加密:密文 c = mᵉ mod n。解密:明文 m = cᵈ mod n。
IB exam questions might ask you to perform simple RSA calculations with small numbers, explain why RSA is secure (the factoring problem), or discuss its limitations such as slow speed and vulnerability to quantum computing attacks. You should practice a complete worked example to be fully prepared.
IB 考题可能要求你用较小的数字进行简单的 RSA 计算,解释为何 RSA 是安全的(因数分解难题),或讨论其局限性,如速度较慢以及易受量子计算攻击。你应当练习一个完整的实例以确保充分准备。
6. Hash Functions | 哈希函数
A hash function takes an input (or message) and returns a fixed-size string of bytes, typically a digest that appears random. Key properties include determinism (same input always gives same output), pre-image resistance (unable to reverse to original input), and collision resistance (difficult to find two different inputs with the same hash). Common algorithms are MD5 (now broken), SHA-1 (deprecated), and SHA-256. Hashing is not encryption—it is a one-way function that cannot be decrypted.
哈希函数接受一个输入(或消息),并返回一个固定大小的字节串,通常是一个看起来随机的摘要。关键特性包括确定性(相同输入始终产生相同输出)、抗原像性(无法逆向回原始输入)和抗碰撞性(难以找到两个不同的输入有相同的哈希值)。常用算法有 MD5(现已破解)、SHA-1(已弃用)和 SHA-256。哈希不是加密——它是一种不可解密的单向函数。
In IB, hash functions are often discussed in the context of password storage and data integrity. Instead of storing a password in plaintext, a system stores its hash. During login, the entered password is hashed and compared with the stored hash. For integrity checks, a downloaded file’s hash can be compared with a published hash to detect tampering.
在 IB 中,哈希函数通常结合密码存储和数据完整性来讨论。系统不存储明文密码,而是存储其哈希值。登录时,输入的密码被哈希后与存储的哈希比较。对于完整性校验,可以将下载文件的哈希与发布的哈希对比,以检测篡改。
7. Digital Signatures | 数字签名
A digital signature provides authentication, non-repudiation, and data integrity. It is created by generating a hash of the message and then encrypting that hash with the sender’s private key. The recipient can verify the signature by decrypting it with the sender’s public key to obtain the original hash, then independently computing the hash of the received message and comparing the two. If they match, the signature is valid, proving the message came from the claimed sender and was not altered.
数字签名提供身份验证、不可否认性和数据完整性。其生成方式是对消息取哈希,然后用发送方的私钥加密该哈希。接收方可以用发送方的公钥解密签名得到原始哈希,再独立计算收到消息的哈希并比较两者。如果匹配,签名有效,证明消息来自声称的发送方且未被篡改。
This technique is fundamental to secure email (S/MIME), software distribution, and blockchain transactions. IB students should be able to describe the process step by step and explain why digital signatures cannot be forged without the private key, as well as how they differ from ordinary handwritten signatures in a digital context.
这项技术是安全邮件(S/MIME)、软件分发和区块链交易的基础。IB 学生应能逐步描述该过程,并解释为何没有私钥就无法伪造数字签名,以及它们与普通手写签名在数字环境中的不同之处。
8. Digital Certificates and PKI | 数字证书与公钥基础设施
A digital certificate binds an entity’s identity to a public key. It is issued by a trusted Certificate Authority (CA) and contains information such as the owner’s name, the public key, the CA’s digital signature, and an expiry date. The Public Key Infrastructure (PKI) is the framework of CAs, registration authorities, and certificate management systems that enable the secure distribution and verification of public keys on a large scale.
数字证书将实体的身份与其公钥绑定在一起。它由受信任的证书颁发机构 (CA) 签发,包含所有者名称、公钥、CA 的数字签名和有效期等信息。公钥基础设施 (PKI) 是由 CA、注册机构和证书管理系统组成的框架,能够实现大规模公钥的安全分发和验证。
When you connect to a website using HTTPS, the server presents its digital certificate. Your browser checks whether the certificate is signed by a trusted CA, whether it is still valid, and whether the domain name matches. This chain of trust prevents man-in-the-middle attacks by ensuring you are indeed communicating with the intended server.
当你通过 HTTPS 连接网站时,服务器会出示其数字证书。你的浏览器会检查证书是否由受信任的 CA 签名、是否仍然有效以及域名是否匹配。这种信任链可以防止中间人攻击,确保你确实在与目标服务器通信。
9. SSL/TLS and Secure Communication | SSL/TLS 与安全通信
SSL (Secure Sockets Layer) and its successor TLS (Transport Layer Security) are cryptographic protocols that provide secure communication over a network, most commonly the internet. The TLS handshake uses asymmetric encryption to authenticate the server and optionally the client, negotiates a symmetric session key, and then encrypts all subsequent data with that symmetric key for performance. This hybrid model ensures both security and efficiency.
SSL(安全套接层)及其后继者 TLS(传输层安全)是提供网络(最典型的是互联网)安全通信的密码协议。TLS 握手使用非对称加密对服务器(可选地对客户端)进行身份验证,协商一个对称会话密钥,然后使用该对称密钥加密所有后续数据,以保证性能。这种混合模式兼顾了安全与效率。
IB students often encounter TLS when discussing HTTPS, secure email (IMAPS, SMTPS), and VPNs. You need to know the steps of the TLS handshake at a conceptual level: client hello, server hello and certificate, key exchange, session key generation, and finalisation. Additionally, you should be aware of common threats such as downgrade attacks and the importance of keeping certificates and protocols up to date.
IB 学生在讨论 HTTPS、安全邮件(IMAPS、SMTPS)和 VPN 时经常会遇到 TLS。你需要在概念层面了解 TLS 握手的步骤:客户端问候、服务器问候与证书、密钥交换、会话密钥生成和完成。此外,你应该意识到常见的威胁,如降级攻击,以及保持证书和协议为最新版本的重要性。
10. Common Vulnerabilities and Attacks | 常见漏洞与攻击
Encryption systems face a range of attacks that IB students should be able to identify and suggest countermeasures for. Brute-force attacks try every possible key; strong encryption uses key lengths that make this computationally infeasible. Man-in-the-middle (MITM) attacks intercept communication, often by presenting a fake certificate. Proper certificate validation and certificate pinning help prevent MITM. Side-channel attacks exploit implementation weaknesses, such as timing or power consumption, rather than mathematical flaws.
加密系统面临多种攻击,IB 学生应能识别并建议对策。暴力攻击尝试所有可能的密钥;强加密使用在计算上不可行的密钥长度来防止这种情况。中间人 (MITM) 攻击通过出示伪造证书来拦截通信。正确的证书验证和证书固定有助于防止 MITM。侧信道攻击利用实现缺陷(如时间或功耗)而非数学漏洞进行攻击。
Other risks include using broken or deprecated algorithms (e.g., DES, RC4, MD5), poor key management (e.g., hard-coded keys in source code), and social engineering to obtain passwords rather than breaking the encryption mathematically. Strong security requires both robust algorithms and sound operational practices. IB questions often ask for a combination of technical and procedural controls.
其他风险包括使用已破解或弃用的算法(如 DES、RC4、MD5)、糟糕的密钥管理(如在源代码中硬编码密钥),以及通过社会工程学获取密码而非从数学上破解加密。强安全性既需要健壮的算法,也需要可靠的操作实践。IB 考题经常要求结合技术与程序控制两方面来回答。
11. Real-world Applications and Ethical Implications | 现实应用与伦理意涵
Encryption is ubiquitous: messaging apps like WhatsApp use end-to-end encryption to ensure only the communicating parties can read messages; online banking and e-commerce rely on TLS to protect financial transactions; and disk encryption tools like FileVault and BitLocker protect data at rest. In the IB curriculum, you may be asked to evaluate the social and ethical impacts of encryption, such as the tension between individual privacy and law enforcement access.
加密无处不在:WhatsApp 等即时通讯应用使用端到端加密确保只有通信双方能阅读消息;在线银行和电子商务依赖 TLS 保护金融交易;FileVault 和 BitLocker 等磁盘加密工具保护静止数据。在 IB 课程中,你可能会被要求评估加密的社会和伦理影响,例如个人隐私与执法部门获取信息之间的紧张关系。
The debate around “backdoors” — deliberate vulnerabilities that allow authorised access to encrypted data — is particularly relevant. While governments argue backdoors are necessary for national security, cybersecurity experts warn that any backdoor can be exploited by malicious actors, weakening security for everyone. IB students should be prepared to discuss these competing perspectives, using balanced arguments and concrete examples.
围绕“后门”(允许授权访问加密数据的故意漏洞)的争论尤为相关。虽然政府认为后门对国家安全是必要的,但网络安全专家警告说,任何后门都可能被恶意行为者利用,从而削弱所有人的安全。IB 学生应准备好用平衡的论点和具体实例来讨论这些相互冲突的观点。
12. Exam Tips and Key Takeaways | 考试技巧与核心要点
When answering encryption questions in IB Computer Science, always define your terms precisely — plaintext, ciphertext, key, algorithm, symmetric, asymmetric, digital signature, and hash. Use the correct terminology and relate your answers to the specific scenario. For Paper 1, be prepared to compare symmetric and asymmetric encryption in a table or short answer. For Paper 2 and the IA, demonstrate an understanding of where encryption fits in a system design, such as protecting data in transit between client and server.
在回答 IB 计算机科学中的加密问题时,始终要精确定义你的术语——明文、密文、密钥、算法、对称、非对称、数字签名和哈希。使用正确的术语并将答案与特定场景联系起来。对于 Paper 1,准备好用表格或简答题形式比较对称和非对称加密。对于 Paper 2 以及内部评估,要展示你理解加密在系统设计中的位置,例如保护客户端和服务器之间传输的数据。
A few essential points to remember: symmetric encryption uses one key, is fast, has a key distribution problem. Asymmetric encryption uses a key pair, solves key distribution, enables digital signatures, but is slower. Hashing is one-way and used for integrity and password storage. Digital signatures require the sender’s private key. Digital certificates trust relies on CAs. And finally, no security measure is 100% foolproof; a layered defence strategy is always the best practice.
务必记住几个要点:对称加密使用单一密钥,速度快,但有密钥分发问题。非对称加密使用密钥对,解决了密钥分发问题,可以实现数字签名,但速度较慢。哈希是单向的,用于完整性和密码存储。数字签名需要发送方的私钥。数字证书的信任依赖于 CA。最后,没有任何安全措施是万无一失的;分层防御策略始终是最佳实践。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导