Encryption 101
ทำไมต้องเข้ารหัสข้อมูล? หลักการเข้ารหัสแบบ Symmetric และ Asymmetric อย่างเข้าใจง่าย
ทำไมต้องเข้ารหัสข้อมูล? หลักการเข้ารหัสแบบ Symmetric และ Asymmetric อย่างเข้าใจง่าย
ลองใช้เครื่องมือเข้ารหัสข้อความง่ายๆ ส่งหากันในห้อง
เป้าหมายการเรียนรู้
- เข้าใจหลักการเข้ารหัส (Encryption) และเหตุผลที่ต้องใช้ในโลกดิจิทัล
- แยกแยะความแตกต่างระหว่าง Symmetric Encryption และ Asymmetric Encryption
- ลองใช้เครื่องมือเข้ารหัสอย่างง่ายในการส่งข้อความที่ปลอดภัย
ทำไมต้องเข้ารหัสข้อมูล?
ลองนึกภาพว่าคุณส่งจดหมายถึงเพื่อน ถ้าคุณไม่ปิดผนึกซอง ใครก็ตามที่อยู่ระหว่างทางสามารถแอบอ่านได้ การส่งข้อมูลบนอินเทอร์เน็ตก็เหมือนกัน ถ้าไม่มีการเข้ารหัส ข้อมูลของเราจะถูกส่งในรูปแบบ Plain Text ที่ใครก็อ่านได้ ไม่ว่าจะเป็นรหัสผ่าน ข้อความแชท หรือข้อมูลบัตรเครดิต การเข้ารหัสคือการ "ปิดผนึก" ข้อมูลให้เฉพาะคนที่มีกุญแจเท่านั้นที่เปิดอ่านได้
สร้างภาพ A clean flat infographic showing the encryption concept. On the left side, a document icon with readable text labeled Plain Text. In the middle, a lock icon with a key representing the encryption process. On the right side, a document icon with scrambled unreadable characters labeled Cipher Text. Arrows flow left to right showing the transformation. Below, a reverse arrow shows decryption with another key icon. Modern minimal educational style with soft blue and green colors on white background. (encryption_concept.jpg)
A clean flat infographic showing the encryption concept. On the left side, a document icon with readable text labeled Plain Text. In the middle, a lock icon with a key representing the encryption process. On the right side, a document icon with scrambled unreadable characters labeled Cipher Text. Arrows flow left to right showing the transformation. Below, a reverse arrow shows decryption with another key icon. Modern minimal educational style with soft blue and green colors on white background.
- HTTPS — เว็บไซต์ที่มีรูปกุญแจ แสดงว่าข้อมูลระหว่างเรากับเว็บถูกเข้ารหัส
- WhatsApp End-to-End Encryption — ข้อความถูกเข้ารหัสตั้งแต่ส่งจนถึงผู้รับ แม้แต่ WhatsApp เองก็อ่านไม่ได้
- WiFi WPA2/WPA3 — การเข้ารหัสสัญญาณ WiFi ป้องกันไม่ให้คนนอกดักจับข้อมูล
- Mobile Banking — ทุกครั้งที่โอนเงิน ข้อมูลจะถูกเข้ารหัสเพื่อป้องกันการดักจับ
ประเภทการเข้ารหัส
Symmetric Encryption (กุญแจเดียวกัน)
Symmetric Encryption ใช้ กุญแจตัวเดียวกันทั้งเข้ารหัสและถอดรหัส เปรียบเหมือนกุญแจบ้าน ใครมีกุญแจดอกนี้ก็เปิดประตูได้ ทั้งคนส่งและคนรับต้องมีกุญแจตัวเดียวกัน ตัวอย่างอัลกอริทึมที่ใช้ ได้แก่ AES (Advanced Encryption Standard) ซึ่งเป็นมาตรฐานที่ใช้กันทั่วโลก
| ข้อดี | ข้อเสีย |
|---|---|
| เข้ารหัสและถอดรหัสเร็วมาก เหมาะกับข้อมูลขนาดใหญ่ | ต้องหาวิธีส่งกุญแจให้อีกฝ่ายอย่างปลอดภัย |
| ใช้ทรัพยากรคอมพิวเตอร์น้อย | ถ้ากุญแจหลุด ข้อมูลทั้งหมดจะถูกถอดรหัสได้ |
| เหมาะกับการเข้ารหัสไฟล์ในเครื่องตัวเอง | ไม่เหมาะกับการสื่อสารระหว่างคนจำนวนมาก |
Asymmetric Encryption (กุญแจคู่)
Asymmetric Encryption ใช้กุญแจ 2 ดอกที่เป็นคู่กัน คือ Public Key สำหรับเข้ารหัส และ Private Key สำหรับถอดรหัส เปรียบเหมือนกล่องไปรษณีย์ ใครก็หย่อนจดหมายเข้าไปได้ (Public Key) แต่เฉพาะเจ้าของที่มีกุญแจเท่านั้นที่เปิดออกมาอ่านได้ (Private Key) ตัวอย่างอัลกอริทึม เช่น RSA และ ECC
| ข้อดี | ข้อเสีย |
|---|---|
| ไม่ต้องแชร์กุญแจลับ ปลอดภัยกว่า | เข้ารหัสและถอดรหัสช้ากว่า Symmetric |
| เหมาะกับการสื่อสารผ่านอินเทอร์เน็ต | ใช้ทรัพยากรคอมพิวเตอร์มากกว่า |
| สามารถยืนยันตัวตนผู้ส่ง (Digital Signature) ได้ | กุญแจมีขนาดใหญ่กว่า Symmetric Key |
สร้างภาพ A clean flat comparison diagram showing Symmetric vs Asymmetric encryption side by side. Left side labeled Symmetric: two people share the same single key icon, with arrows showing encrypt and decrypt using the same key. Right side labeled Asymmetric: one person has a public key (open lock icon) and private key (closed lock icon), showing how sender encrypts with public key and receiver decrypts with private key. Color coded blue for symmetric and green for asymmetric. Modern minimal educational style on white background. (symmetric_vs_asymmetric.jpg)
A clean flat comparison diagram showing Symmetric vs Asymmetric encryption side by side. Left side labeled Symmetric: two people share the same single key icon, with arrows showing encrypt and decrypt using the same key. Right side labeled Asymmetric: one person has a public key (open lock icon) and private key (closed lock icon), showing how sender encrypts with public key and receiver decrypts with private key. Color coded blue for symmetric and green for asymmetric. Modern minimal educational style on white background.
Hashing
Hash ไม่ใช่การเข้ารหัสเพราะไม่สามารถ "ถอดรหัส" กลับเป็นข้อมูลเดิมได้ Hashing เป็นการแปลงข้อมูลทางเดียว (One-Way Function) ไม่ว่าข้อมูลจะยาวแค่ไหน ผลลัพธ์ที่ได้จะมีขนาดเท่ากันเสมอ และถ้าข้อมูลเปลี่ยนแม้แต่ตัวอักษรเดียว Hash ที่ได้จะเปลี่ยนไปอย่างสิ้นเชิง
- เก็บรหัสผ่าน — ระบบไม่เก็บรหัสผ่านจริง แต่เก็บ Hash ของรหัสผ่าน เวลาล็อกอินจะ Hash รหัสที่กรอกแล้วเทียบกับ Hash ที่เก็บไว้
- ตรวจสอบไฟล์ — ดาวน์โหลดไฟล์แล้วเทียบ Hash เพื่อยืนยันว่าไฟล์ไม่ถูกแก้ไขระหว่างทาง
- Digital Signature — ใช้ Hash ร่วมกับ Asymmetric Encryption เพื่อยืนยันตัวตนผู้ส่ง
| ข้อมูลเดิม | Hash (SHA-256) |
|---|---|
| hello | 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e7343... |
| Hello | 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1... |
| hello! | ce06092fb948d9ffac7d1a376e404b26b7575bcc11ee05a4615... |
| สวัสดี | a7b1f4d8c3e5f2a1b9c8d7e6f5a4b3c2d1e0f9a8b7c6d5e4f3... |
สร้างภาพ A clean flat infographic showing the hashing concept. Multiple inputs of different sizes (short text, long document, image file) all passing through a hash function box (depicted as a meat grinder or funnel icon) producing fixed-length output strings of the same size. An important note showing that changing even one character in input produces completely different output. One-way arrow indicating irreversibility. Modern minimal educational style with orange and purple accents on white background. (hashing_concept.jpg)
A clean flat infographic showing the hashing concept. Multiple inputs of different sizes (short text, long document, image file) all passing through a hash function box (depicted as a meat grinder or funnel icon) producing fixed-length output strings of the same size. An important note showing that changing even one character in input produces completely different output. One-way arrow indicating irreversibility. Modern minimal educational style with orange and purple accents on white background.
กิจกรรม: ส่งข้อความเข้ารหัส
ลองใช้เครื่องมือ CyberChef (เปิดได้จาก gchq.github.io/CyberChef) เพื่อเข้ารหัสข้อความง่ายๆ แล้วส่งให้เพื่อนถอดรหัส ฝึกทั้ง Symmetric Encryption (AES) และ Hashing (SHA-256) เพื่อให้เข้าใจความแตกต่างระหว่างการเข้ารหัสแบบย้อนกลับได้กับแบบย้อนกลับไม่ได้
Symmetric Encryption กับ Asymmetric Encryption ต่างกันอย่างไร?
ข้อใดกล่าวถูกต้องเกี่ยวกับ Hashing?


