Data integrity — validation and verification
แนะนำใหม่
15:06
ความปลอดภัย ความเป็นส่วนตัว และความถูกต้อง
ตอนนี้ วินาทีนี้ อุปกรณ์ของคุณกำลังถูกโจมตี ไม่ใช่โดยบุคคลที่งอตัวอยู่หน้าคีย์บอร์ด — แต่โดยกองทัพของบอทอัตโนมัติ ที่สแกนอย่างไม่มีที่สิ้นสุด…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| software/ˈsɒftweə/ | The programs and instructions that tell a computer what to do. |
| format check/ˈfɔːmæt tʃek/ | A check that data matches a required pattern. |
| integrity/ɪnˈteɡrɪti/ | ความสมบูรณ์ของข้อมูล |
| Validation/ˌvælɪˈdeɪʃn/ | Checking whether data meets specified rules for acceptable values or format. |
| Verification/ˌverɪfɪˈkeɪʃn/ | Double entry compares the two email addresses and reports a mismatch if they differ. The computer compares two copies, and it would accept a wrong address typed identically twice. |
| range check/reɪndʒ tʃek/ | |
| limit check | A check that a value is above or below a set limit. |
| existence (lookup) check | A check that a value appears in an allowed list or table. |
| length check/leŋθ tʃek/ | A check that data has the required number of characters. |
| type / character check | A check that data or its characters are of the required kind. |
| field/fiːld/ | A named component of a record, with its own value and type. |
| presence check/ˈprezəns tʃek/ | A check that a required field has been filled in. |
| check digit/tʃek ˈdɪdʒɪt/ | |
| pseudocode/ˈsuːdəʊkəʊd/ | A language-independent description of an algorithm using structured, programming-like statements. |
| Double entry/ˈdʌbl ˈentri/ | The data is entered twice, by the same person or by two people, and the computer compares the two versions and reports any difference. A new password is the everyday case. |
| Visual check/ˈvɪʒuːəl tʃek/ | The person compares what is on the screen with the original source document and corrects any difference before saving. |
| source document | The original document containing data to be entered or checked. |
| parity check/ˈpærɪti tʃek/ | |
| bit/bɪt/ | A binary digit, taking the value zero or one. |
| byte/baɪt/ | A group of eight bits, commonly used as a unit of data storage. |
| even parity | A method of making the total number of ones even by adding a bit. |
| checksum/ˈtʃeksəm/ | |
| block of data | A group of data treated as one unit for processing or transfer. |
| algorithm/ˈælɡərɪθəm/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| server/ˈsɜːvə/ | A computer or program that provides services or resources in response to requests from clients. |
| cyclic redundancy check/ˈsaɪklɪk rɪˈdʌndənsi tʃek/ | |
| polynomial division | A way of dividing mathematical expressions to find an answer and a remainder. |
| parity block/ˈpærɪti blɒk/ | A grid of data with extra bits used to detect and locate a single-bit error. |
| parity block check/ˈpærɪti blɒk tʃek/ | |
| row parity bit | An extra bit that makes the number of ones in a row even or odd. |
| parity byte/ˈpærɪti baɪt/ | An extra byte containing parity bits for the columns of a data block. |
| column parity | A check using the number of ones in each column to detect errors. |
| Encryption/enˈkrɪpʃn/ | The process of using a key to turn readable data into unreadable data. |
ทุกตัวเลขผ่านการตรวจสอบทั้งหมด
- ในเดือนกันยายนปี 1999 เครื่องบินสำรวจดาวอังคาร Mars Climate Orbiter ของ NASA เร่งเครื่องยนต์เพื่อเข้าวงโคจรและไม่เคยได้ยินเสียงอีกต่อไป มันบินต่ำกว่าแผน 170 กิโลเมตรและไหม้ดับลง
- ซอฟต์แวร์ทีมหนึ่งสร้างตัวเลขแรงขับเป็นปอนด์-ฟุตวินาที; ซอฟต์แวร์ฝั่งผู้รับคาดหวังหน่วยนิวตัน-วินาที ทุกค่าเป็นตัวเลขที่มีรูปแบบถูกต้องอยู่ในช่วงที่เหมาะสม ทุกค่าผิดไป 4.45 เท่า
- ไม่มีรูปแบบตรวจสอบใดจะจับมันได้ เพราะข้อมูลไม่ได้มีรูปแบบผิดพลาด มันแค่ไม่ใช่สิ่งที่อ้างว่าเป็น $327 ล้าน
- บทเรียนนี้คือครอบครัวการตรวจสอบสองกลุ่มที่ปกป้อง ความสมบูรณ์ (integrity): Validation ซึ่งถามว่าข้อมูลมีความสมเหตุสมผลหรือไม่, และ Verification ซึ่งถามว่าข้อมูลถูกคัดลอกมาถูกต้องหรือไม่ และช่องว่างระหว่างสองสิ่งนี้ที่ทำให้ดาวอังคารตก

สองคำถาม
- ข้อมูลมี ความสมบูรณ์ (integrity) เมื่อมีความแม่นยำ สอดคล้องกัน และครบถ้วน
- Validation เป็นการตรวจสอบอัตโนมัติว่าข้อมูลที่ป้อนเข้ามาสมเหตุสมผลและเป็นไปตามกฎที่กำหนด ถามว่า: สิ่งนี้สมเหตุสมผลไหม?
- Verification ตรวจสอบว่าข้อมูลถูกป้อนหรือถ่ายโอนมาถูกต้องโดยการเปรียบเทียบกับแหล่งกำเนิดหรือค่าที่คำนวณใหม่ ถามว่า: สิ่งนี้ถูกคัดลอกมาถูกต้องไหม?
- ทั้งสองอย่างไม่พิสูจน์ว่าข้อมูลเป็นความจริง ต้องใช้ทั้งสองอย่างร่วมกัน
ห้องปฏิบัติการแนวคิดการคำนวณ
Classify concrete examples by the computing idea they demonstrate.
วิธีการ Validation
| การตรวจสอบ | กฎ | ตัวอย่าง |
|---|---|---|
| range check | ระหว่างขอบเขตสองค่า | เดือนคือ 1 ถึง 12 |
| limit check | บนด้านหนึ่งของค่าจำกัดเดียว | อายุ ≥ 18 |
| การตรวจสอบการมีอยู่ (lookup) check | ค่าอยู่ในรายการหรือตาราง | รหัสสินค้ามีการมีอยู่จริง |
| การตรวจสอบความยาว | จำนวนตัวอักษรถูกต้อง | รหัสไปรษณีย์จำนวน 6 ตัวอักษร |
| การตรวจสอบประเภท / ตัวอักษร | ประเภทข้อมูลถูกต้อง | ช่องโทรศัพท์อนุญาตให้ใช้เฉพาะตัวเลขเท่านั้น |
| การตรวจสอบรูปแบบ | ตรงกับรูปแบบที่กำหนด | อีเมลมี @ |
| การตรวจสอบความพร้อม | ช่องที่จำเป็นไม่ว่างเปล่า | มีการกรอกชื่อ |
| เลขตรวจสอบ | เลขเพิ่มที่คำนวณจากเลขอื่น | ISBN, หมายเลขบัตร |
Checking that a month entered is between 1 and 12 is a:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A range check confirms a value lies within sensible limits.
Match each validation check to its purpose.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Presence = not empty; format = matches a pattern; check digit = computed to catch mistyped digits.
An extra digit computed from the others to catch a mistyped number (as on ISBNs and card numbers) is a ______ digit.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A check digit is recomputed from the rest and compared, catching most single-digit and transposition errors.
Worked example: name the check the pseudocode performs
| Pseudocode | Check |
|---|---|
IF x < 0 OR x > 10 THEN OUTPUT "Invalid" |
range check: ระหว่างสองค่าจำกัด |
IF x = "" THEN OUTPUT "Invalid" |
presence check: ไม่ว่างเปล่า |
IF NOT(x = "Red" OR x = "Yellow" OR x = "Blue") THEN OUTPUT "Invalid" |
existence (lookup) check: เป็นหนึ่งในรายการ |
IF LENGTH(x) <> 6 THEN OUTPUT "Invalid" |
length check: หกตัวอักษร |
IF MID(x, 1, 1) < "A" OR MID(x, 1, 1) > "Z" THEN OUTPUT "Invalid" |
format check: ตัวอักษรแรกเป็นตัวอักษร |
- การจดทะเบียนรถที่มีหนึ่งตัวอักษร สามตัวเลข และสองตัวอักษร ต้องใช้ format check ในแต่ละตำแหน่งและ length check สำหรับหกตัวอักษร วันเดือนปีเกิดต้องใช้ format check (
DD/MM/YYYY), range check (เดือนคือ 1 ถึง 12, ปีไม่อยู่ในอนาคต) และ presence check.
Match each line of pseudocode to the validation check it performs.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Empty test = presence; character count = length; two limits = range; a list of allowed values = existence or lookup.
ตัวอย่างวิธีทำ: เลขตรวจสอบ และสิ่งที่มันตรวจไม่พบ
- แผนงานอย่างง่าย: เลขตรวจสอบคือเศษเมื่อผลรวมของเลขหารด้วย 10, แปะท้ายตัวเลข
4162มีผลรวมของเลข 13, ดังนั้นจึงเก็บเป็น41623. - A user types
41523: the sum is now 12, the check digit should be 2, so the error is caught. - ผู้ใช้พิมพ์
14623: สองตัวอักษรแรกสลับกัน, แต่ผลรวมยังคงเป็น 13, ดังนั้นเลขตรวจสอบตรงกันและข้อผิดพลาด ไม่ถูกตรวจจับ แผนงานจริง (ISBN, หมายเลขบัตร) ให้น้ำหนักแก่แต่ละตำแหน่งเพื่อให้การสลับเปลี่ยนผลลัพธ์

สิ่งที่ไม่สามารถตรวจสอบได้
- การตรวจสอบจับข้อมูลที่ รูปแบบผิด หรือเกินขอบเขต
- It cannot catch data that has the right format and is factually wrong.
Bobtyped forBibpasses every check; so did every thrust figure sent to Mars. - สำหรับสิ่งนั้นคุณต้องการการยืนยันเทียบกับแหล่งที่มา, และบุคคลที่อ่านสิ่งที่พวกเขาพิมพ์
Why can validation still let bad data through?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Validation checks the form, not the truth — a correctly formatted but wrong value passes.
การยืนยันระหว่างกรอกข้อมูล
- การกรอกซ้ำ: ข้อมูลถูกกรอกสองครั้ง, โดยบุคคลเดียวกันหรือโดยสองคน, และคอมพิวเตอร์เปรียบเทียบทั้งสองเวอร์ชันและรายงานความแตกต่างใดๆ กรณีพาสเวิร์ดใหม่คือกรณีทั่วไป
- การตรวจสอบด้วยสายตา: บุคคลเปรียบเทียบสิ่งที่อยู่บนหน้าจอกับเอกสารต้นฉบับเดิมและแก้ไขความแตกต่างใดๆ ก่อนบันทึก
- ทั้งสองปกป้องความสมบูรณ์โดยการมั่นใจว่าข้อมูลที่จัดเก็บตรงกับแหล่งที่มา

Asking a user to type a new password twice is an example of:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Double entry compares two typed copies to verify the data was entered correctly.
การยืนยันระหว่างการถ่ายโอนข้อมูล
- บิตสามารถพลิกในการเดินทาง parity check เพิ่มบิตเพิ่มเติมหนึ่งบิตต่อไบต์เพื่อให้อριθ্মะของ 1 เป็นคู่ (even parity) หรือคี่; ผู้รับนับอีกครั้ง, และบิตที่พลิกเพียงตัวเดียวล้มเหลวในการนับ
- checksum คือค่าที่คำนวณจากบล็อกข้อมูลโดยอัลกอริทึมและส่งพร้อมกับมัน; ผู้รับคำนวณใหม่อีกครั้งและเปรียบเทียบ การถ่ายโอนไฟล์วิดีโอจากกล้องไปยังเซิร์ฟเวอร์ทำงานแบบนี้: ความไม่ตรงกันหมายถึงการส่งซ้ำ
- cyclic redundancy check (CRC) checksum ที่แข็งแกร่งกว่าโดยใช้การหารพหุนาม, จับรูปแบบข้อผิดพลาดได้มากกว่ามาก

One extra bit makes the count of 1s even; a flipped bit breaks it

Compute, send, recompute, compare
A parity check works by:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The parity bit makes the count of 1s even or odd; the receiver re-counts to detect a single-bit error.
Which are verification methods used during data transfer? Select ทั้งหมด that apply.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Parity and checksums recompute a value at the receiving end. Double entry and a visual check happen during data entry.
A byte parity check detects every possible transmission error in that byte.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Two flipped bits leave the parity of the count of 1s unchanged, so they pass. Parity detects any odd number of flipped bits.
ตัวอย่างวิธีทำ: บล็อก parity ตั้งตำแหน่งบิต
- parity block check เรียบเรียงไบต์ในตาราง: แต่ละไบต์มีบิต parity ของแถว, และไบต์ parity เพิ่มเติมหนึ่งไบต์ถือ parity คอลัมน์ของไบต์ด้านบน
- ไบต์สี่ตัวถูกส่งด้วย even parity, ตามด้วยไบต์ parity นับ 1 ในทุกแถวและคอลัมน์: ไบต์ 3 มีห้าและคอลัมน์ 4 มีสาม, ทั้งคู่เป็นคี่
- บิตที่แถวและคอลัมน์นั้นตัดกันคือบิตที่เปลี่ยน, ดังนั้นจึงรีเซ็ตจาก 1 เป็น 0 Bounce parity bit เดียวตรวจจับข้อผิดพลาด; บล็อกระบุตำแหน่งและแก้ไข

One row wrong, one column wrong: the bit is at the crossing
Put the steps of a parity block check in order.
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Rows detect, columns detect, the crossing locates, and the flip corrects. That is what a block adds over a single parity bit.
การ์ดนี้ได้รับการแก้ไขแล้ว จึงแสดงเป็นภาษาอังกฤษจนกว่าคำแปลจะได้รับการอัปเดต
Worked example: which check catches which error
- A user types their date of birth as
31/02/2009, then types their email address twice. Which check catches which error, and what is the difference? - Validation: a calendar validity check rejects
31/02/2009, because February never has 31 days. The computer tests the day against the month and year. - Verification 核对: double entry compares the two email addresses and reports a mismatch if they differ. The computer compares two copies, and it would accept a wrong address typed identically twice.
- Validation asks whether the data is sensible; verification asks whether it was entered correctly.

Sensible, or copied correctly: two different questions
Which statement is correct?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Validation tests sensibility against rules; verification tests that the data was entered/transferred without change.
Verification checks whether data was copied or entered without change — but does not prove that it was unchanged or factually correct.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Double entry and checksums can detect errors, but matching results do not prove the data is unchanged or factually correct.
คะแนนที่หลุดหายไป
- ตัวเลขตรวจสอบ (Check digit) คือการตรวจสอบเมื่อป้อนข้อมูล; พาริตี้ (Parity) และ checksum ตรวจสอบการส่งข้อมูล อย่าจำแนกอยู่ในหัวข้อที่ผิด
- Neither check proves that data is true. Validation says "reasonable"; verification says "matches the source"
- A byte parity check misses two flipped bits in the same byte, เพราะthey cancel. บอกว่า "single-bit errors"
- Encryption เป็นมาตรการความปลอดภัย มันทำอะไรไม่ได้กับความสมบูรณ์
คุณเข้าใจแล้ว
- validation = กฎอัตโนมัติระหว่างกรอก: range, limit, existence, length, type, format, presence, check digit; มันไม่สามารถจับค่าที่มีรูปแบบถูกต้องแต่ผิด
- การตรวจสอบ เมื่อเข้าสู่ระบบ = การบันทึกสองชั้น และ การตรวจสอบด้วยสายตา; เมื่อถ่ายโอนข้อมูล = parity (byte หรือบล็อก), checksum, CRC
- บล็อก parity จะ ระบุตำแหน่ง bit ที่เปลี่ยนไปที่จุดตัดของแถวและคอลัมน์ที่ล้มเหลว
- การตรวจสอบถามว่า "สมเหตุสมผลไหม?"; การตรวจสอบถามว่า "คัดลอกถูกต้องหรือไม่?"; ไม่มีข้อใดถามว่า "เป็นความจริงหรือไม่?"
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้