Data integrity · سلامة البيانات
Keeping data correct
- Integrity means data stays accurate. Two techniques protect it: validation and verification.
- They sound similar but do different jobs — a classic exam distinction.
الحفاظ على صحة البيانات
- النزاهة تعني بقاء البيانات دقيقة. تقنيتان تحميانها: التحقق الصالح والتحقق من الصحة.
- يبدو اسماهما متشابهين لكنهما يؤديان وظائف مختلفة — تمييز كلاسيكي في الامتحانات.
Validation vs verification
- Validation checks data is reasonable as it is entered. Examples:
- Range check (age 0–120), length check (a phone number), format check (an email has an
@), presence check (not left blank).
- Range check (age 0–120), length check (a phone number), format check (an email has an
- Verification checks data was copied correctly. Examples:
- Double entry (type a password twice), or a visual check (read it back).
التحقق الصالح مقابل التحقق من الصحة
- التحقق الصالح يتأكد من أن البيانات معقولة أثناء إدخالها. أمثلة:
- فحص النطاق (العمر 0–120)، فحص الطول (رقم هاتف)، فحص التنسيق (بريد إلكتروني يحتوي على
@)، فحص الوجود (لم يُترك فارغاً).
- فحص النطاق (العمر 0–120)، فحص الطول (رقم هاتف)، فحص التنسيق (بريد إلكتروني يحتوي على
- التحقق من الصحة يتأكد من أن البيانات تم نسخها بشكل صحيح. أمثلة:
- الإدخال المزدوج (اكتب كلمة مرور مرتين)، أو الفحص البصري (اقرأها مجدداً).
Checking data in transit
- When data travels, bits can flip. A checksum or check digit catches that.
- The sender calculates a small number from the data; the receiver recalculates it. If they differ, the data was corrupted.
التحقق من البيانات أثناء النقل
- أثناء نقل البيانات، قد تنقلب البتات. يلتقط ذلك رقم التحقق أو رقم الفحص.
- يحسب المرسل رقماً صغيراً بناءً على البيانات؛ ويعيد حسابه المستقبل. إذا اختلفا، فقد تلفت البيانات.
number = "1389"
print(sum(int(d) for d in number) % 10) # a one-digit checksum
Your turn
- Compute a simple check digit by summing the digits modulo 10. Real systems (like barcodes and ISBNs) use cleverer versions of this idea.
Covers: A-Level 6.2 (validation/verification), IGCSE 2.2 (error detection).
دورك الآن
- احسب رقماً بسيطاً للتحقق بجمع الأرقام modulo 10. الأنظمة الحقيقية (مثل الباركود وISBNs) تستخدم نسخاً أكثر ذكاءً من هذه الفكرة.
يغطي: A-Level 6.2 (التحقق الصالح/التحقق من الصحة)، IGCSE 2.2 (كشف الأخطاء).
Common mistakes
- A checksum or check digit spots accidental changes to data.
- Validation checks data is sensible; verification checks it was entered correctly.
أخطاء شائعة
- رقم التحقق أو رقم الفحص يكشف عن التغييرات العرضية في البيانات.
- التحقق الصالح يتأكد من أن البيانات منطقية؛ والتحقق من الصحة يتأكد من إدخالها بشكل صحيح.
Hashes detect tampering · الكاشفات تكشف التعديل
Re-hash the data and compare: any change flips the digest. · أعد تجزئة البيانات وقارنها: أي تغيير يقلب الهاش.
A simple checksum helps catch typing errors. Add up the digits of number and take the result modulo 10. Print that single check digit. · مجموع تحقق بسيط يساعد في اكتشاف أخطاء الكتابة. اجمع أرقام number وأخذ النتيجة modulo 10. اطبع ذلك الرقم التحققي الوحيد.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.
Now be the receiver. The sender transmitted the digits with check digit 8, but one digit got corrupted on the way. Recompute the checksum of received and print ERROR if it does not equal sent_check, else OK. · الآن كن المستقبل. أرسل المرسل الأرقام مع رقم التحقق 8، لكن رقمًا واحدًا تالف في الطريق. أعد حساب مجموع التحقق لـ received وطبع ERROR إذا لم يساوِ sent_check، وإلا اطبع OK.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.