Encryption and hashing
แนะนำใหม่
12:11
การเข้ารหัสทำงานอย่างไร
ดูที่ไอคอนลูกกุญแจในแถบที่อยู่ของเบราว์เซอร์ คุณพิมพ์ชื่อธนาคารของคุณแล้วบางทีแล็ปท็อปของคุณก็มั่นใจเลยว่ากำลังคุยกับธนาคารจริงๆ — และ…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| secret key | A value kept private and used to encrypt or decrypt data. |
| symmetric/sɪˈmetrɪk/ | สมมาตร |
| Encryption/enˈkrɪpʃn/ | The process of using a key to turn readable data into unreadable data. |
| codebooks | Books containing codes or keys used to protect secret messages. |
| shared secret/ʃeəd ˈsiːkrɪt/ | Confidential information known to authorised parties and used for a purpose such as authentication or encryption. |
| public channel | A way of sending information that other people can listen to. |
| RSA | An encryption method that uses a public key and a matching private key. |
| private key/ˈpraɪvət kiː/ | กุญแจส่วนตัว |
| asymmetric/ˌeɪsɪˈmetrɪk/ | ไม่สมมาตร |
| one-way function | A process that is easy to perform but very hard to reverse. |
| hashing/ˈhæʃɪŋ/ | The process of calculating an initial record address from a key. |
| plaintext/ˈpleɪntekst/ | |
| ciphertext/ˈsaɪfətekst/ | |
| decrypt/dɪˈkrɪpt/ | ถอดรหัส |
| confidentiality/ˌkɒnfɪˌdenʃiˈæləti/ | Keeping information private so only authorised people can read it. |
| algorithm/ˈælɡərɪθəm/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| AES/ˌeɪ iː ˈes/ | A fast encryption method that uses the same key to encrypt and decrypt data. |
| key distribution/kiː ˌdɪstrɪˈbjuːʃn/ | Securely providing or establishing the cryptographic keys that communicating parties need. |
| key pair/kiː peə/ | คู่กุญแจ |
| public key/ˈpʌblɪk kiː/ | กุญแจสาธารณะ |
| key exchange | The process of sharing or agreeing a key for secure communication. |
| client/ˈklaɪənt/ | A device or program that requests a service or resource from a server. |
| session key/ˈseʃn kiː/ | กุญแจ-session |
| server/ˈsɜːvə/ | A computer or program that provides services or resources in response to requests from clients. |
| byte/baɪt/ | A group of eight bits, commonly used as a unit of data storage. |
| HTTPS/ˌeɪtʃ tiː tiː piː ˈes/ | A secure set of rules for transferring web pages and other web content. |
| SSH | A set of rules for securely connecting to and controlling a computer from another location. |
| Diffie–Hellman key agreement | A method for two parties to agree a shared secret over a public channel. |
| cryptographic hash/ˌkrɪptəˈɡræfɪk hæʃ/ | ฟังก์ชันแฮชทางรหัส |
| digest/ˈdaɪdʒest/ | สรุปข้อมูล |
| salted password hashes | Stored values made by hashing passwords with added random data to make guessing harder. |
| database/ˈdeɪtəbeɪs/ | An organised collection of data that can be accessed and managed. |
| integrity/ɪnˈteɡrɪti/ | The accuracy, completeness and protection of data against unauthorised or unintended alteration. |
| message authentication code | A value made using a secret key to check who sent a message and whether it changed. |
| digital signature/ˈdɪdʒɪtl ˈsɪɡnɪtʃə/ | A cryptographic value created with a signing key and checked with a corresponding public key to verify data integrity and signing origin. |
คนแปลกหน้าสองคนตกลงรหัสลับในที่สาธารณะ
- นี่คือปัญหาที่ฟังดูเป็นไปไม่ได้ คุณและร้านค้าไม่เคยเจอกันมาก่อนและไม่มีความสัมพันธ์กันอะไรเลย ทุกสิ่งที่พูดต่อกันถูกทุกคนได้ยินตลอด การตกลงรหัสลับให้สำเร็จ
- จนถึงปี 1976 คำตอบคือทำไม่ได้: การเข้ารหัสแบบสมมาตรต้องการส่งกุญแจล่วงหน้าโดยผู้จัดส่งหรือบุคคลโดยตรง นี่คือเหตุผลที่คู่มือรหัสสงครามต้องพิมพ์และขนส่ง
- จากนั้น Diffie, Hellman และต่อมา Rivest, Shamir และ Adleman แสดงให้เห็นว่าทำได้ โดยใช้กุญแจที่ล็อกได้แต่เปิดไม่ได้ และอีกกุญแจหนึ่งที่เปิดได้แต่ล็อกไม่ได้ การซื้อออนไลน์ของคุณทุกครั้งที่ผ่านมามีพื้นฐานมาจากสิ่งนี้
- บทเรียนนี้เกี่ยวกับ การเข้ารหัสแบบสมมาตร และ การเข้ารหัสแบบอสมมาตร เหตุผลที่ระบบจริงใช้ทั้งสองอย่าง และฟังก์ชันทางเดียวที่เรียกว่า hashing
คำศัพท์เฉพาะ
- การเข้ารหัส เปลี่ยน plaintext ที่อ่านได้ให้เป็น ciphertext ที่อ่านไม่ออกโดยใช้กุญแจ; การ ถอดรหัส คือการย้อนกลับด้วยกุญแจที่เหมาะสม
- การเข้ารหัสปกป้อง ความลับ: สำเนาที่ถูกดักจับไม่สามารถเข้าใจได้ มัน ไม่ ป้องกันข้อมูลจากการถูกดักจับ หน่วงเวลา หรือลบ
- ความแข็งแกร่งอยู่ที่ คีย์ ไม่ใช่การเก็บอัลกอริทึมไว้เป็นความลับ อัลกอริทึมถูกเผยแพร่และศึกษาอย่างละเอียดเพื่อให้พบจุดอ่อนโดยเพื่อนมากกว่าศัตรู
การเข้ารหัสแบบสมมาตร
- การเข้ารหัสแบบสมมาตร ใช้ กุญแจเดียวกัน ทั้งในการเข้ารหัสและการถอดรหัส AES เป็นตัวอย่างมาตรฐาน
- มัน เร็ว จึงเหมาะสำหรับ ข้อมูลจำนวนมาก: ดิสก์ทั้งหมด สตรีมวิดีโอ ไฟล์ขนาดใหญ่
- จุดอ่อนคือ การกระจายกุญแจ: กุญแจต้องถึงอีกฝ่ายโดยไม่ถูกดักจับ และหากถูกดักจับทั้งระบบจะพังลง กับ $n$ คนที่ต้องการคุยส่วนตัวเป็นคู่ จำนวนกุญแจที่ต้องการเพิ่มขึ้นตามกำลังสองของ $n$
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:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Symmetric encryption shares one secret key — fast, but it must be distributed securely.
การเข้ารหัสแบบอสมมาตร
- การเข้ารหัสแบบอสมมาตร ให้แต่ละผู้ใช้มี คู่กุญแจ: public key ที่เผยแพร่ต่อโลก และ private key ที่ไม่เคยเปิดเผย
- สิ่งใดที่เข้ารหัสด้วย public key สามารถถอดรหัสได้ เฉพาะ ด้วย private key ที่ตรงกัน ดังนั้นเพื่อส่งข้อความลับให้ Alice คุณต้องเข้ารหัสด้วย public key ของเธอ และเพียงเธอเท่านั้นที่จะอ่านได้
- ไม่จำเป็นต้องแลกเปลี่ยนกุญแจล่วงหน้า ซึ่งแก้ปัญหาที่บทเรียนเปิดด้วย ราคาที่ต้องจ่ายคือมัน ช้ากว่ามาก ดังนั้นจึงไม่ใช้สำหรับข้อมูลปริมาณมาก

หนึ่งกุญแจล็อก อีกกุญแจเปิด และเพียงกุญแจเดียวที่เป็นความลับ

Match each cryptographic tool to what it uses.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
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:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Encrypting with the recipient's public key means only their matching private key can decrypt it.
Match each kind of encryption to its main weakness.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The hybrid scheme uses each to cover the other's weakness: asymmetric to deliver the key, symmetric to carry the data.
ตัวอย่างวิธีทำ: ส่งข้อความลับ
- อธิบายว่า Asymmetric encryption ช่วยให้ Bob ส่งข้อความลับไปยัง Alice ได้ แม้ไม่เคยพบกัน [3]
- Alice เผยแพร่ public key ของเธอซึ่งใครก็ตามมีได้ รวมถึงผู้ดักฟัง
- Bob เข้ารหัสข้อความด้วย public key ของ Alice ciphertext สามารถถอดรหัสได้เฉพาะด้วย private key ที่ตรงกัน
- Alice ถอดรหัสด้วย private key ของเธอซึ่งเธอไม่เคยแชร์ ผู้ดักฟังที่มี public key และ ciphertext ไม่สามารถกู้คืนข้อความได้
- ข้อผิดพลาดที่พบบ่อยที่สุดคือการบอกว่า Bob เข้ารหัสด้วย กุญแจของเขาเอง ตรวจสอบว่าแต่ละขั้นตอนใช้กุญแจของใคร
Bob wants Alice to be sure a message really came from him. Which key does Bob use to create the digital signature?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Only Bob holds his private key, so only he can produce the signature; Alice checks it with Bob's public key. Confidentiality uses the receiver's keys, a signature uses the sender's.
แนวทางผสมผสาน ซึ่งเป็นสิ่งที่เกิดขึ้นจริง
- แบบสมมาตรเร็วแต่แชร์กุญแจไม่ได้ แบบอสมมาตรแชร์กุญแจได้แต่ช้า ระบบจริงใช้แต่ละแบบในสิ่งที่มันเก่ง
- Client สร้าง session key แบบสุ่ม เข้ารหัส กุญแจขนาดเล็กนั้น ด้วย public key ของ server แล้วส่ง Server ถอดรหัสด้วย private key ของมัน และตอนนี้ทั้งสองฝ่ายมี session key เดียวกัน
- Every byte ของการสนทนาจริงจะถูกเข้ารหัส แบบสมมาตร ด้วย session key นั้น: เร็ว และการขั้นตอนแบบอสมมาตรที่ช้าเกิดขึ้นเพียงครั้งเดียว กับข้อมูลเล็กน้อย
- นี่คือวิธีการทำงานของ HTTPS และ SSH

*แบบอสมมาตรเพื่อตกลงกุญแจ แบบสมมาตรเพื่อพาข้อมูล

In the hybrid approach used by HTTPS, asymmetric encryption is used to:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Slow asymmetric crypto just shares a session key; the bulk data then uses fast symmetric encryption.
Put the steps of this example hybrid encryption scheme in order.
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The slow asymmetric step runs once, on a few bytes; everything after it is fast symmetric encryption.
Hashing
- cryptographic hash เปลี่ยนอินพุตขนาดใดๆ ให้เป็น digest ขนาดคงที่ อินพุตเดิมให้ digest เหมือนเดิมเสมอ และการเปลี่ยนแปลงเล็กน้อยในอินพุตทำให้ digest เปลี่ยนไปทั้งหมด
- มัน one-way: ไม่สามารถกู้คืนอินพุตจาก digest ได้ นั่นคือจุดประสงค์ทั้งหมด และเป็นสิ่งที่ทำให้มันต่างจากการเข้ารหัสซึ่งออกแบบมาเพื่อย้อนกลับได้
- การใช้: เก็บรหัสผ่าน โดยระบบเก็บเฉพาะ digest และเปรียบเทียบ digests lúcเข้าสู่ระบบ ทำให้ฐานข้อมูลที่ขโมยไม่ได้รหัสผ่าน; และการตรวจสอบ ความสมบูรณ์ โดยคำนวณ digest ของไฟล์ใหม่และเปรียบเทียบกับเดิมเพื่อตรวจจับการเปลี่ยนแปลง

A cryptographic hash produces a fixed-size ____ from an input of any size.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The same input always gives the same digest, a small change gives a completely different one, and the input cannot be recovered from it.
ตัวอย่างวิธีทำ: ทำไมต้อง hash รหัสผ่านแทนการเข้ารหัสมัน
- เว็บไซต์เก็บรหัสผ่านของผู้ใช้เป็น hash แทนข้อความที่เข้ารหัส อธิบายเหตุผล.
- Encryption สามารถ ย้อนกลับได้: มี key ที่ somewhere ที่แปลงค่าที่เก็บกลับเป็นรหัสผ่าน และผู้โจมตีที่ได้ฐานข้อมูลอาจได้ key ด้วย
- Hashing เป็น one-way ดังนั้นฐานข้อมูล digests ที่ถูกขโมยจึงไม่ให้รหัสผ่าน และแม้พนักงานของเว็บไซต์เองก็อ่านไม่ได้
- Login ยังทำได้เพราะระบบ hash สิ่งที่ผู้ใช้พิมพ์และเปรียบเทียบ digests ไม่ใช่รหัสผ่านโดยตรง
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.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
One-wayness plus avalanche is what makes hashes good for storing passwords and checking integrity.
Why store passwords as hashes rather than encrypted? Select ทั้งหมด that apply.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A fixed-size digest may indeed be shorter, but that is not the security reason. Irreversibility is.
คะแนนที่หลุดหายไป
- เพื่อส่งข้อความลับให้ใครบางคนคุณต้องใช้ public key ของเขา ไม่ใช่ของคุณ บอกว่าแต่ละขั้นตอนใช้กุญแจของใคร
- จุดอ่อนของ Symmetric คือ การแจกจ่ายกุญแจ; จุดอ่อนของ Asymmetric คือ ความเร็ว ระบบผสมผสานใช้แต่ละอย่างเพื่อครอบคลุมจุดอ่อนของอีกฝ่าย
- การทำ Hash เป็นแบบ ทางเดียว และ ไม่ใช่การเข้ารหัส: ไม่มีกุญแจและไม่มีอะไรให้ถอดรหัส
- การเข้ารหัสปกป้องความลับเพียงอย่างเดียว มันไม่หยุดยั้งการดักจับ การลบ หรือการแก้ไขข้อความโดยไม่ถูกตรวจพบ: สำหรับสิ่งนั้นคุณต้องใช้ Hash
คุณเข้าใจแล้ว
- การเข้ารหัส เปลี่ยน ข้อความplain เป็น ciphertext ด้วยกุญแจและปกป้อง ความลับ เท่านั้น; ความแข็งแกร่งอยู่ที่กุญแจ ไม่ใช่ที่การซ่อนอัลกอริทึม
- Symmetric: กุญแจร่วมกันหนึ่งตัว, เร็ว, เหมาะกับข้อมูลจำนวนมาก, อ่อนแอเรื่อง การแจกจ่ายกุญแจ · Asymmetric: มี public key สำหรับเข้ารหัสและ private key สำหรับถอดรหัส ไม่ต้องแลกเปลี่ยนล่วงหน้า แต่ช้ากว่า
- ระบบ hybrid ที่ใช้โดย HTTPS และ SSH ส่ง session key แบบสุ่มที่เข้ารหัสด้วย asymmetric แล้วส่งข้อมูลต่อด้วย symmetric
- cryptographic hash สร้าง digest ขนาดคงที่ เป็นแบบ ทางเดียว และใช้สำหรับรหัสผ่านและการตรวจสอบความสมบูรณ์
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้