Symmetric & Asymmetric Encryption Explained | 对称与非对称加密详解

📚 Symmetric & Asymmetric Encryption Explained | 对称与非对称加密详解

Encryption is one of the most important topics in IGCSE Computer Science. It ensures that data remains confidential when sent over insecure networks such as the Internet. In this article, we will explore two fundamental types of encryption — symmetric and asymmetric — in a clear, exam-focused way.

加密是 IGCSE 计算机科学中最重要的主题之一。它确保数据在不安全的网络(如互联网)上传输时保持机密性。在本文中,我们将以清晰且紧扣考点的方式,探讨两种基本的加密类型——对称加密与非对称加密。


1. What Is Encryption? | 什么是加密?

Encryption is the process of converting plaintext (readable data) into ciphertext (unreadable data) using an algorithm and a key. Only someone with the correct key can decrypt the ciphertext back into plaintext.

加密是使用算法和密钥将明文(可读数据)转换为密文(不可读数据)的过程。只有拥有正确密钥的人才能将密文解密回明文。

Encryption is used to protect data from unauthorised access — for example, when shopping online, sending emails, or storing sensitive files. The two main types of encryption are:

加密用于防止数据被未经授权的人访问——例如,在网上购物、发送电子邮件或存储敏感文件时。两种主要的加密类型是:

  • Symmetric encryption — uses the same key for encryption and decryption.
  • 对称加密——使用同一把密钥进行加密和解密。
  • Asymmetric encryption — uses a pair of keys (public and private).
  • 非对称加密——使用一对密钥(公钥和私钥)。

2. Symmetric Encryption | 对称加密

Symmetric encryption, also called private-key encryption, uses the same key to encrypt and decrypt data. The sender and receiver must both know this key and keep it secret. If an attacker obtains the key, the encryption is useless.

对称加密,也称为私钥加密,使用同一把密钥对数据进行加密和解密。发送方和接收方都必须知道这把密钥并对其保密。如果攻击者获得了密钥,加密就毫无意义了。

In symmetric encryption, the key must be shared securely before any encrypted communication can take place. This is often done in person, by phone, or through another secure channel. The security of a symmetric system depends entirely on the secrecy of the key.

在对称加密中,密钥必须在任何加密通信发生之前安全地共享。这通常通过当面、电话或其他安全渠道完成。对称系统的安全性完全依赖于密钥的保密性。

Examples of symmetric encryption algorithms include:

对称加密算法的例子包括:

  • Caesar cipher — each letter is shifted by a fixed number of places.
  • 凯撒密码——每个字母按固定位数进行移位。
  • Vigenère cipher — uses a keyword to shift letters by varying amounts.
  • 维吉尼亚密码——使用关键字对字母进行不同位数的移位。
  • AES (Advanced Encryption Standard) — a modern block cipher used worldwide.
  • AES(高级加密标准)——一种在全球范围内使用的现代分组密码。

Plaintext → Encryption (Key K) → Ciphertext → Decryption (Key K) → Plaintext

The same key K is used on both sides. The main advantages of symmetric encryption are that it is fast and efficient, even for large amounts of data.

同一把密钥 K 在两侧使用。对称加密的主要优点是即使对大量数据来说,它也是快速且高效的。


3. The Key-Distribution Problem | 密钥分发问题

One major weakness of symmetric encryption is the key-distribution problem. How do you send the secret key to the receiver without anyone else seeing it? If you send it over the same insecure channel, an eavesdropper could intercept it.

对称加密的一个主要弱点是密钥分发问题。如何在不被别人看到的情况下将秘密密钥发送给接收方?如果你通过同一条不安全的信道发送,窃听者就可能截获它。

Imagine two people, Alice and Bob, who have never met and want to communicate securely over the Internet. If they use symmetric encryption, they need to agree on a key first — but any message they send to agree on the key could be intercepted by an attacker, Eve.

想象爱丽丝和鲍勃两个人,他们从未见过面,想通过互联网安全地通信。如果他们使用对称加密,就需要先商定一把密钥——但他们为商定密钥而发送的任何消息都可能被攻击者伊芙截获。

This is exactly the problem that asymmetric encryption solves. It allows two parties to exchange encrypted data without ever sharing a secret key.

这正是非对称加密要解决的问题。它允许双方在不共享秘密密钥的情况下交换加密数据。


4. Asymmetric Encryption | 非对称加密

Asymmetric encryption, also called public-key encryption, uses two different but mathematically related keys: a public key and a private key. The public key is shared openly with everyone; the private key is kept secret by its owner. Data encrypted with one key can only be decrypted with the other key.

非对称加密,也称为公钥加密,使用两个不同但在数学上相关的密钥:公钥和私钥。公钥向所有人公开共享;私钥由其所有者保密。用一把密钥加密的数据只能用另一把密钥解密。

Consider Alice sending a message to Bob. Alice encrypts the message using Bob’s public key, which is available to anyone. Once encrypted, only Bob can decrypt it using his private key. Even if Eve intercepts the ciphertext, she cannot decrypt it without Bob’s private key.

考虑爱丽丝向鲍勃发送消息。爱丽丝使用鲍勃的公钥对消息进行加密,公钥对任何人都是可用的。一旦加密,只有鲍勃可以使用他的私钥解密。即使伊芙截获了密文,她也没有鲍勃的私钥,无法解密。

The relationship between the two keys is one-way in practice: it is computationally infeasible to derive the private key from the public key. This is usually based on difficult mathematical problems, such as factoring very large numbers.

两把密钥之间的关系在实际上是单向的:从公钥推导出私钥在计算上是不可行的。这通常基于困难的数学问题,例如分解非常大的数字。

Plaintext → Encrypt (Bob’s Public Key) → Ciphertext → Decrypt (Bob’s Private Key) → Plaintext

The most famous asymmetric algorithm is RSA, named after its inventors Rivest, Shamir, and Adleman. RSA is widely used in secure communications on the Internet.

最著名的非对称算法是 RSA,以其发明者 Rivest、Shamir 和 Adleman 的名字命名。RSA 广泛用于互联网上的安全通信。


5. How RSA Works (Simplified) | RSA 的工作原理(简化版)

RSA relies on the mathematical difficulty of factoring the product of two large prime numbers. Here is a simplified outline of how RSA key generation works:

RSA 依赖于将两个大质数相乘的结果进行因式分解的数学难度。以下是 RSA 密钥生成工作原理的简化概述:

  1. Choose two large prime numbers, p and q.

    选择两个大的质数 p 和 q。

  2. Compute n = p × q. The value of n is used as part of both the public and private keys.

    计算 n = p × q。n 的值用作公钥和私钥的一部分。

  3. Compute φ(n) = (p − 1) × (q − 1), known as Euler’s totient function.

    计算 φ(n) = (p − 1) × (q − 1),即欧拉函数。

  4. Choose a public exponent e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1.

    选择公钥指数 e,满足 1 < e < φ(n) 且 gcd(e, φ(n)) = 1。

  5. Compute the private exponent d such that d × e ≡ 1 mod φ(n).

    计算私钥指数 d,满足 d × e ≡ 1 mod φ(n)。

The public key is (e, n), and the private key is (d, n). To encrypt a message M, compute:

公钥是 (e, n),私钥是 (d, n)。要加密消息 M,计算:

C = Mᵉ mod n

To decrypt the ciphertext C, the receiver computes:

要解密密文 C,接收方计算:

M = Cᵈ mod n

Because p and q are extremely large (hundreds of digits), factoring n back into p and q would take an impractically long time, making the private key secure.

由于 p 和 q 极大(有数百位),将 n 分解回 p 和 q 需要极长的时间,因此私钥是安全的。


6. Symmetric vs Asymmetric — Comparison Table | 对称与非对称——对比表

For your exam, you need to be able to compare the two approaches in terms of speed, key management, and security. The table below summarises the key differences:

在考试中,你需要能够从速度、密钥管理和安全性方面比较这两种方法。下表总结了主要区别:

Feature | 特征 Symmetric | 对称 Asymmetric | 非对称
Number of keys used | 使用的密钥数量 One shared key | 一把共享密钥 Two keys (public + private) | 两把密钥(公钥 + 私钥)
Speed | 速度 Fast | 快 Slow | 慢
Key distribution | 密钥分发 Difficult — must exchange the secret key securely | 困难——必须安全地交换秘密密钥 Easy — public key can be shared openly | 容易——公钥可以公开共享
Security model | 安全模型 Secrecy of the key | 密钥的保密性 Mathematical difficulty of factoring | 分解的数学难度
Example algorithms | 算法示例 Caesar, Vigenère, AES | 凯撒、维吉尼亚、AES RSA, Diffie-Hellman | RSA、Diffie-Hellman
Typical use | 典型用途 Encrypting large volumes of data | 加密大量数据 Securely exchanging keys and digital signatures | 安全交换密钥和数字签名

7. Real-World Applications | 实际应用场景

In real-world systems, symmetric and asymmetric encryption are often used together. This combination is called a hybrid system and takes advantage of the strengths of both approaches.

在实际系统中,对称和非对称加密常常一起使用。这种组合称为混合系统,利用了两种方法的优势。

When you visit a secure website (HTTPS), the browser and the server first use asymmetric encryption to exchange a session key. Once the session key is securely shared, both sides switch to symmetric encryption (usually AES) for the rest of the communication. This works well because:

当你访问一个安全网站(HTTPS)时,浏览器和服务器首先使用非对称加密来交换一把会话密钥。一旦会话密钥被安全地共享,双方就切换到对称加密(通常是 AES)进行后续的通信。这样做效果很好,因为:

  • Asymmetric encryption is used only once, so its slower speed has little impact.

    非对称加密只使用一次,因此其较慢的速度影响很小。

  • The session key is unique for each connection — even if one session is compromised, other sessions remain secure.

    会话密钥对每个连接都是唯一的——即使一个会话被破坏,其他会话仍然是安全的。

  • Symmetric encryption is fast enough to encrypt all the data in the session.

    对称加密的速度足够快,可以加密会话中的所有数据。

Asymmetric encryption is also used for digital signatures. Here, the sender encrypts a hash of the message using their private key. Anyone can decrypt it using the sender’s public key, which proves that the message really came from that sender and was not tampered with.

非对称加密还用于数字签名。在这里,发送方使用自己的私钥加密消息的哈希值。任何人都可以使用发送方的公钥解密,这证明了消息确实来自该发送方并且未被篡改。


8. Common Exam Questions | 常见考点问题

Understanding the definitions is important, but you must also be able to explain and analyse encryption in context. Here are some common exam-style questions you should be prepared to answer:

理解定义很重要,但你还必须能够在具体情境中解释和分析加密。以下是一些你应准备回答的常见考试风格问题:

  • Explain how symmetric encryption is used to send a message privately.

    解释如何使用对称加密来私下发送消息。

  • Describe the key-distribution problem and how asymmetric encryption solves it.

    描述密钥分发问题以及非对称加密如何解决它。

  • Why is asymmetric encryption considered more secure than symmetric encryption for key exchange?

    为什么非对称加密在密钥交换方面被认为比对称加密更安全?

  • Compare the speed and security of symmetric and asymmetric encryption.

    比较对称和非对称加密的速度和安全性。

  • Explain the role of the public key and private key in public-key encryption.

    解释公钥和私钥在公钥加密中的作用。

For CIE IGCSE, you are expected to know that symmetric encryption is faster but has the key-distribution problem, while asymmetric encryption solves the key-distribution problem but is slower. You should also know that the two can be combined in hybrid systems.

在 CIE IGCSE 考试中,你需要知道对称加密更快但存在密钥分发问题,而非对称加密解决了密钥分发问题但较慢。你还需要知道两者可以结合在混合系统中。


9. Common Mistakes to Avoid | 常见错误提醒

Many students lose marks on this topic due to a few repeated mistakes. Here are the most important ones to avoid:

许多学生因为几个重复出现的错误而丢分。以下是最需要避免的几个错误:

  • Confusing the keys: Remember — in asymmetric encryption, a message encrypted with the public key is decrypted with the private key, and vice versa.

    混淆密钥:记住——在非对称加密中,用公钥加密的消息用私钥解密,反之亦然。

  • Thinking the public key must be kept secret: The public key is called public for a reason — it can be shared with anyone.

    认为公钥必须保密:公钥之所以叫公钥是有原因的——它可以与任何人共享。

  • Forgetting why symmetric encryption is faster: Asymmetric encryption involves complex mathematical operations with very large numbers, making it computationally expensive.

    忘记为什么对称加密更快:非对称加密涉及对大数进行复杂的数学运算,因此计算开销很大。

  • Not mentioning the secure key exchange in symmetric encryption: Always state that the key must be shared through a secure channel before symmetric encryption can be used.

    未提及对称加密中的安全密钥交换:始终说明,在使用对称加密之前,必须通过安全渠道共享密钥。


10. Summary | 总结

Symmetric encryption uses one key for both encryption and decryption. It is fast and suitable for encrypting large amounts of data, but it has a key-distribution problem: the key must be securely shared between sender and receiver before communication begins.

对称加密使用同一把密钥进行加密和解密。它速度快,适合加密大量数据,但存在密钥分发问题:在通信开始前,密钥必须在发送方和接收方之间安全地共享。

Asymmetric encryption uses a pair of keys — a public key and a private key. It solves the key-distribution problem by allowing the public key to be shared openly, but it is slower due to the complex mathematics involved. RSA is a well-known asymmetric algorithm.

非对称加密使用一对密钥——公钥和私钥。它通过允许公开共享公钥解决了密钥分发问题,但由于涉及复杂的数学运算,速度较慢。RSA 是一种著名的非对称算法。

In practice, both methods are combined: asymmetric encryption securely exchanges a session key, and symmetric encryption encrypts the actual data. This hybrid approach is what makes modern Internet communication secure.

在实践中,两种方法结合使用:非对称加密安全地交换会话密钥,对称加密对实际数据进行加密。这种混合方法使现代互联网通信变得安全。

Make sure you can draw and explain the encryption/decryption process for both types, and that you can clearly state the advantages and disadvantages of each. Good luck with your revision!

请确保你能画出并解释两种类型的加密/解密过程,并且能清楚地陈述每种方法的优缺点。祝复习顺利!

Published by TutorHao | IGCSE Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading