Book 7 · Chapter 4
Data integrity and cybersecurity
B7·4This chapter is in the ebook.
Read it in full on cswithzak.com. Every question has its mark scheme and every program is ready to run. The free practice for each section is below, with the short code the book prints beside it.
For the whole chapter
- Topic pageData integrity and cybersecurity (2029–2031)
B7·4·T - QuizData integrity and cybersecurity
B7·4·Q1 - LabNetworks Lab — error detection
B7·4·X1 - LabPython example py-parity
B7·4·X2 - LabNetworks Lab — encryption
B7·4·X3
§4.2 Cybersecurity
Short code B7·4·2
- FlashcardsFlashcards §4.2: Core principles & threats
B7·4·F2 - FlashcardsFlashcards §4.2: Defences & encryption
B7·4·F3
How errors get into data
Short code B7·4·10
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Parity bits
Short code B7·4·11
data = "1100101"
ones = 0
for bit in data:
if bit == "1":
ones = ones + 1
if ones % 2 == 0:
print("even:", "0" + data, " odd:", "1" + data)
else:
print("even:", "1" + data, " odd:", "0" + data)Output
even: 01100101 odd: 11100101
Parity blocks and the parity byte
Short code B7·4·12
def ones(b):
n = 0
for bit in b:
if bit == "1":
n = n + 1
return n
rows = ["01100101", "10101100", "00011011", "11011101"]
pbyte = ""
for c in range(8):
col = ""
for r in rows:
col = col + r[c]
if ones(col) % 2 == 0:
pbyte = pbyte + "0"
else:
pbyte = pbyte + "1"
print("parity byte:", pbyte)Output
parity byte: 00001111
Echo checks and checksums
Short code B7·4·13
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Check digits
Short code B7·4·14
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Automatic repeat request
Short code B7·4·15
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Choosing an error check
Short code B7·4·16
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
The five core principles
Short code B7·4·17
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
How the principles are threatened
Short code B7·4·18
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Attacks on passwords, networks and servers
Short code B7·4·19
print("PIN, 4 digits:", 10 ** 4)
print("8 small letters:", 26 ** 8)
print("8 of a-z A-Z 0-9:", 62 ** 8)Output
PIN, 4 digits: 10000 8 small letters: 208827064576 8 of a-z A-Z 0-9: 218340105584896
Malware
Short code B7·4·20
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Tricking people and websites
Short code B7·4·21
def build(name, pw):
q = "SELECT * FROM Users"
q = q + " WHERE Name = '" + name
q = q + "' AND Password = '"
return q + pw + "'"
print(build("ali", "secret123"))
print(build("ali", "x' OR '1'='1"))Output
SELECT * FROM Users WHERE Name = 'ali' AND Password = 'secret123' SELECT * FROM Users WHERE Name = 'ali' AND Password = 'x' OR '1'='1'
Keeping people and accounts safe
Short code B7·4·22
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Guarding software and networks
Short code B7·4·23
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Why encrypt?
Short code B7·4·24
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Symmetric and asymmetric encryption
Short code B7·4·25
def xor(bits, key):
out = ""
for i in range(len(bits)):
if bits[i] == key[i]:
out = out + "0"
else:
out = out + "1"
return out
plain = "01001000"
key = "10110110"
cipher = xor(plain, key)
print("ciphertext:", cipher)
print("decrypted: ", xor(cipher, key))Output
ciphertext: 11111110 decrypted: 01001000
Past-paper practice
Short code B7·4·90
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Workbook: Data integrity and cybersecurity
Short code W7·4 · Computer Systems Workbook
The write-in workbook for this chapter has drills, exam-style practice, trace tables, fix-the-mistake and mark-it-yourself pages. Its full mark schemes and an interactive version arrive here with the chapter.


