Encryption | 加密

📚 Encryption | 加密

Encryption is the process of converting readable data into an unreadable format to prevent unauthorised access. It is a fundamental element of modern cybersecurity, ensuring confidentiality when data is stored or transmitted. In IGCSE Computer Science, you need to understand the different types of encryption, how keys are used, and where encryption is applied in everyday technology.

加密是将可读数据转换为不可读格式以防止未授权访问的过程。它是现代网络安全的基石,在数据存储或传输时确保机密性。在 IGCSE 计算机科学中,你需要理解不同类型的加密、密钥的使用方式以及加密在日常技术中的应用。

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

Encryption transforms plaintext (original data) into ciphertext (scrambled data) using an algorithm and a key. Only someone with the correct key can decrypt the ciphertext back to plaintext. The goal is to keep information secret from eavesdroppers or thieves.

加密使用算法和密钥将明文(原始数据)转换为密文(打乱的数据)。只有拥有正确密钥的人才可以将密文解密回明文。其目的是对窃听者或窃取者保密信息。


2. Plaintext and Ciphertext | 明文与密文

Plaintext is the original, readable message before encryption. Ciphertext is the encrypted, scrambled version of the message. The encryption process takes the plaintext and a key as input and produces ciphertext. Decryption reverses this process: it takes the ciphertext and a key and reconstructs the plaintext.

明文是加密前原始可读的消息。密文是加密后被打乱的消息版本。加密过程以明文和密钥为输入并产生密文。解密则逆转该过程:以密文和密钥为输入,重建明文。

For example, if the plaintext is ‘HELLO’, after encryption the ciphertext might look like ‘KHOOR’ (depending on the cipher). Anyone intercepting ‘KHOOR’ cannot understand it without the decryption key.

例如,如果明文是 ‘HELLO’,加密后密文可能看起来像 ‘KHOOR’(取决于所用的密码)。任何截获 ‘KHOOR’ 的人在没有解密密钥的情况下无法理解它。


3. Symmetric Encryption | 对称加密

In symmetric encryption, the same key is used for both encryption and decryption. The sender and receiver must share this secret key beforehand. It is fast and efficient for large amounts of data, but the key exchange must be secure. If the key is intercepted, the communication is compromised.

在对称加密中,加密和解密使用相同的密钥。发送方和接收方必须事先共享这个秘密密钥。它对大量数据来说快速高效,但密钥交换必须安全。如果密钥被截获,通信就会被破坏。

Examples of symmetric algorithms include AES (Advanced Encryption Standard) and DES (Data Encryption Standard).

对称算法的例子包括 AES(高级加密标准)和 DES(数据加密标准)。


4. Asymmetric Encryption | 非对称加密

Asymmetric encryption, also called public-key cryptography, uses two mathematically related keys: a public key and a private key. The public key can be shared openly, but the private key is kept secret. Data encrypted with the public key can only be decrypted with the matching private key, and vice versa.

非对称加密,也称为公钥密码学,使用两个数学上相关的密钥:一个公钥和一个私钥。公钥可以公开分享,但私钥必须保密。用公钥加密的数据只能用对应的私钥解密,反之亦然。

This solves the key distribution problem of symmetric encryption. However, asymmetric encryption is slower and requires more computational power. It is often used to securely exchange a symmetric session key for a faster connection.

这解决了对称加密的密钥分发问题。然而,非对称加密较慢且需要更多的计算能力。它常被用于安全地交换对称会话密钥,以便建立更快的连接。


5. Public and Private Keys | 公钥与私钥

The public key is like a lock that anyone can use to secure a message. The private key is the unique key that opens that lock. In a typical communication, Bob uses Alice’s public key to encrypt a message. Only Alice can decrypt it with her private key. This ensures that even if the public key is known, the message remains confidential.

公钥就像一把锁,任何人都可以用它来保护消息。私钥是打开这把锁的唯一钥匙。在典型的通信中,鲍勃使用爱丽丝的公钥加密消息。只有爱丽丝可以用她的私钥解密。这确保了即使公钥已知,消息仍然保密。

Similarly, Alice can sign a message by encrypting a hash of it with her private key. Bob can verify the signature using Alice’s public key, proving the message came from Alice and was not altered.

类似地,爱丽丝可以通过用自己的私钥加密消息的哈希来签署消息。鲍勃可以用爱丽丝的公钥验证签名,证明消息来自爱丽丝且未被篡改。


6. Caesar Cipher: A Simple Example | 凯撒密码:一个简单示例

The Caesar cipher is one of the oldest and simplest symmetric encryption techniques. It works by shifting each letter in the plaintext by a fixed number of positions in the alphabet. This shift value is the key.

凯撒密码是最古老、最简单的对称加密技术之一。它通过将明文中的每个字母在字母表中移动固定数量的位置来工作。这个移动值就是密钥。

For example, with a shift of 3, ‘A’ becomes ‘D’, ‘B’ becomes ‘E’, and ‘Z’ wraps to ‘C’. The plaintext ‘HELLO’ encrypts to ‘KHOOR’. To decrypt, the receiver shifts back by the same number.

例如,移动 3 位,’A’ 变成 ‘D’,’B’ 变成 ‘E’,’Z’ 绕回成 ‘C’。明文 ‘HELLO’ 加密为 ‘KHOOR’。解密时,接收方按相同数字反向移动。

The Caesar cipher is extremely weak by modern standards because there are only 25 possible keys. It can be broken easily by brute force or frequency analysis.

按照现代标准,凯撒密码极其脆弱,因为只有 25 种可能的密钥。它可以通过暴力破解或频率分析轻易破解。


7. Vigenère Cipher | 维吉尼亚密码

The Vigenère cipher improves on Caesar by using a keyword to apply different shifts to each letter. Each letter of the keyword determines the shift for the corresponding letter of the plaintext. If the keyword is shorter than the message, it repeats.

维吉尼亚密码通过使用一个关键词对每个字母应用不同的移位来改进凯撒密码。关键词的每个字母决定了明文中对应字母的移位数。如果关键词比消息短,则重复使用。

For instance, plaintext ‘ATTACK’ with keyword ‘KEY’ gives shifts K=10, E=4, Y=24, then repeating. The ciphertext becomes ‘KXKWXI’. This polyalphabetic approach makes frequency analysis much harder.

例如,明文 ‘ATTACK’ 使用关键词 ‘KEY’,得到移位 K=10, E=4, Y=24,然后重复。密文变为 ‘KXKWXI’。这种多表替代方法使频率分析困难得多。

Though stronger than Caesar, the Vigenère cipher can still be broken with modern techniques. Today, it is mainly studied for its historical importance and to illustrate the principles of more complex ciphers.

尽管比凯撒密码强,维吉尼亚密码仍能被现代技术破解。如今,研究它主要是因其历史重要性,并用以说明更复杂密码的原理。


8. Modern Encryption Protocols | 现代加密协议

Modern systems use strong algorithms such as AES for symmetric encryption and RSA or ECC for asymmetric encryption. AES typically uses key sizes of 128, 192, or 256 bits, making brute-force attacks impractical. RSA relies on the difficulty of factoring large prime numbers.

现代系统使用强大的算法,如用于对称加密的 AES 和用于非对称加密的 RSA 或 ECC。AES 通常使用 128、192 或 256 位的密钥长度,使暴力破解变得不切实际。RSA 则依赖于大素数分解的难度。

These algorithms are combined in protocols like TLS to provide confidentiality, integrity, and authentication on the internet.

这些算法在 TLS 等协议中结合使用,在互联网上提供机密性、完整性和身份验证。


9. Digital Signatures | 数字签名

A digital signature provides authentication and data integrity. The sender creates a hash of the message and encrypts that hash with their private key. The encrypted hash is sent along with the message. The receiver decrypts the hash with the sender’s public key and compares it to a freshly computed hash of the message. If they match, the message is verified as authentic and unaltered.

数字签名提供身份验证和数据完整性。发送方创建消息的哈希,并用其私钥加密该哈希。加密后的哈希随消息一起发送。接收方用发送方的公钥解密哈希,并将其与重新计算的消息哈希进行比较。如果匹配,则验证消息是真实且未被更改的。

Digital signatures are used in software distribution, financial transactions, and email security.

数字签名用于软件分发、金融交易和电子邮件安全。


10. SSL/TLS and HTTPS | SSL/TLS 与 HTTPS

SSL (Secure Sockets Layer) and its successor TLS (Transport Layer Security) are protocols that encrypt data sent over a network. HTTPS (HTTP Secure) is the combination of HTTP with TLS. When you see a padlock icon in your browser, TLS is protecting the communication between your device and the web server.

SSL(安全套接字层)及其继任者 TLS(传输层安全)是对网络传输数据进行加密的协议。HTTPS(HTTP 安全)是 HTTP 与 TLS 的结合。当你在浏览器中看到挂锁图标时,TLS 正在保护你的设备与网络服务器之间的通信。

TLS uses both asymmetric and symmetric encryption. Asymmetric encryption is used during the handshake to agree on a shared symmetric session key. Subsequent data transfer uses symmetric encryption for speed. This hybrid approach combines the security of public-key encryption with the efficiency of symmetric encryption.

TLS 同时使用非对称和对称加密。在握手阶段使用非对称加密来协商一个共享的对称会话密钥。随后数据传输使用对称加密以提高速度。这种混合方法将公钥加密的安全性与对称加密的效率相结合。


11. Advantages and Disadvantages of Encryption | 加密的优缺点

Advantages: Encryption protects sensitive data (e.g., passwords, bank details) from unauthorised access. It ensures confidentiality during transmission and storage. It also supports data integrity and authentication through digital signatures.

优点:加密保护敏感数据(如密码、银行信息)免受未授权访问。它确保传输和存储过程中的机密性。它还通过数字签名支持数据完整性和身份验证。

Disadvantages: Strong encryption can slow down systems due to the computational overhead. If encryption keys are lost, the data may become permanently inaccessible. Attackers can still try social engineering or exploit other vulnerabilities. Some governments restrict the use of strong encryption.

缺点:强加密可能因计算开销而拖慢系统。如果加密密钥丢失,数据可能永久无法访问。攻击者仍然可以尝试社会工程学攻击或利用其他漏洞。一些政府限制强加密的使用。


12. Encryption in Practice: Password Storage | 加密实践:密码存储

A particularly important application is storing user passwords securely. Plain text passwords must never be saved. Instead, a cryptographic hash function (such as SHA-256 or bcrypt) is used to convert the password into a fixed-size hash. A hash is a one-way function: it cannot be reversed to obtain the original password.

一个特别重要的应用是安全地存储用户密码。绝不能保存明文密码。取而代之的是使用加密哈希函数(如 SHA-256 或 bcrypt)将密码转换为固定大小的哈希值。哈希是单向函数:它无法逆转以获得原始密码。

When a user logs in, the system hashes the entered password and compares it against the stored hash. Salts (random data added before hashing) prevent attackers from using precomputed rainbow tables. This technique is not strictly encryption but is a core security concept often examined alongside encryption.

当用户登录时,系统对输入的密码进行哈希处理,并与存储的哈希进行比较。盐(哈希前添加的随机数据)可防止攻击者使用预计算的彩虹表。这种技术严格来说并非加密,但却是与加密一同考察的核心安全概念。


Published by TutorHao | 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