Asymmetric encryption
Two keys instead of one
- Symmetric encryption has a problem: you must somehow share the secret key first.
- Asymmetric encryption uses a pair of keys: a public key and a private key.
ใช้สองกุญแจแทนหนึ่ง
- การเข้ารหัสแบบสมมาตรมีปัญหา: คุณจำเป็นต้อง แบ่งปันกุญแจลับ某种 way ก่อน
- การเข้ารหัสแบบไม่สมมาตร (Asymmetric) ใช้ คู่ ของกุญแจ: กุญแจสาธารณะ และ กุญแจส่วนตัว
The padlock idea
- Your public key is like an open padlock you hand out to everyone.
- Anyone can lock a message shut with it — but only your private key can open it.
- So people send you secrets safely without ever sharing a secret key. That is the breakthrough.
ความคิดเรื่องกุญแจ
- คีย์สาธารณะของคุณเปรียบเสมือนกุญแจเปิดที่มอบให้ทุกคน
- ทุกคนสามารถล็อคข้อความด้วยมันได้ — แต่มีเพียง คีย์ส่วนตัว ของคุณเท่านั้นที่จะเปิดได้
- ดังนั้นผู้คนจึงส่งความลับ到你的的安全 โดยไม่เคยแชร์คีย์ลับ เลย นี่คือจุดเปลี่ยนสำคัญ
A tiny RSA
- RSA is real asymmetric encryption. With tiny numbers you can see it work:
- Encrypting and decrypting use different keys, yet the message comes back.
RSA ขนาดเล็ก
- RSA เป็นระบบเข้ารหัสแบบไม่สมมาตรจริง ๆ ด้วยตัวเลขขนาดเล็กคุณสามารถเห็นการทำงาน:
n, e, d = 33, 3, 7 # public key (e, n), private key (d, n)
cipher = (7 ** e) % n # lock 7 with the public key
print((cipher ** d) % n) # unlock with the private key -> 7
- การเข้ารหัสและการถอดรหัสใช้ คีย์ ที่แตกต่างกัน แต่ข้อความกลับคืนมา
Where you use it daily
- It also works in reverse for digital signatures (next lessons).
- Every time you see HTTPS, asymmetric encryption is quietly setting up a secure connection.
Covers: IGCSE 2.3 (asymmetric, public/private keys), A-Level 17.1, AP CSP.
การใช้ในชีวิตประจำวัน
- ยังทำงานในทางกลับสำหรับ ลายเซ็นดิจิทัล (บทเรียนถัดไป)
- ทุกครั้งที่คุณเห็น HTTPS ระบบเข้ารหัสแบบไม่สมมาตรกำลังตั้งค่าการเชื่อมต่อที่ปลอดภัยอยู่เบื้องหลัง
ครอบคลุม: IGCSE 2.3 (ไม่สมมาตร, คีย์สาธารณะ/ส่วนตัว), A-Level 17.1, AP CSP.
Common mistakes
- A public key encrypts; only the matching private key decrypts.
- Never share the private key.
ข้อผิดพลาดที่พบบ่อย
- คีย์สาธารณะทำการเข้ารหัส; มีเพียงคีย์ส่วนตัวที่ตรงกันเท่านั้นที่ถอดรหัสได้
- ห้ามแชร์คีย์ส่วนตัวเด็ดขาด
Public & private keys · กุญแจสาธารณะและกุญแจส่วนตัว
Anyone encrypts with your public key; only your private key decrypts. · ใครก็ตามสามารถเข้ารหัสด้วย กุญแจสาธารณะ ของคุณ; มีเพียง กุญแจส่วนตัว ของคุณเท่านั้นที่จะถอดรหัสได้
Here is a tiny RSA with public key (e, n) and private key (d, n). Encrypt message with the public key (cipher = message**e % n), then decrypt with the private key (plain = cipher**d % n). Print plain — it should return to the original. · นี่คือ RSA ขนาดเล็กที่มีกุญแจสาธารณะ (e, n) และกุญแจส่วนตัว (d, n). เข้ารหัส message ด้วย กุญแจสาธารณะ (cipher = message**e % n), แล้วถอดรหัสด้วย กุญแจส่วนตัว (plain = cipher**d % n). พิมพ์ผลลัพธ์ plain — ควรจะกลับคืนค่าเริ่มต้น
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
The same keys also work in reverse — that is a digital signature. Sign with the private key (sig = message**d % n), then let anyone verify with the public key (sig**e % n). Print whether the verified value equals message. · กุญแจเดียวกันนี้ยังใช้ สลับทิศทาง ได้ — นั่นคือการลายเซ็นดิจิทัล. ลายเซ็นด้วย กุญแจส่วนตัว (sig = message**d % n), แล้วให้ใครก็ได้ตรวจสอบด้วย กุญแจสาธารณะ (sig**e % n). พิมพ์ว่าค่าที่ตรวจสอบแล้วเท่ากับ message หรือไม่
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่