Compression, Encryption & Hashing

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

8 Terms

1
New cards
term image


Lossless compression should be used because:

  • It does not permanently remove any data.

  • The original data can be fully reconstructed/restored after decompression.

  • This is important because the user is sending text, so losing data could make it unreadable or change its meaning.


🧠 Easy way to remember:“NO LOSS = EXACT TEXT”

Lossless = No data lost → Original restored → Text stays correct

2
New cards
term image

A good way to remember this is:

🔐 Encryption = LOCK it, so it can be UNLOCKED.
#⃣ Hashing = FINGERPRINT it, so it can be CHECKED.

Encryption converts readable data (plaintext) into unreadable ciphertext using an encryption algorithm and a key. It is reversible, so the original data can be recovered using the correct key.

There are two main types of encryption:

  • Symmetric encryption uses the same key to encrypt and decrypt the data. This is useful for the robot because large amounts of stored data or network communication can be encrypted and decrypted efficiently. However, the key must be kept secret and securely shared.

  • Asymmetric encryption uses a public key and a private key. The public key can be shared, while the private key is kept secret. Data encrypted with the public key can be decrypted using the corresponding private key. It can therefore be used whenrobots/users need to communicate securely without already sharing a secret key. It can also help verify the identity of the sender.

For the robot's stored data, encryption is useful because if someone gains unauthorised access to the robot's storage, they will see ciphertext rather than the original information. The data can only be understood if the attacker has the correct key. Therefore, encryption provides confidentiality.

For communication over the wireless network, encryption is important because wireless data could be intercepted. Encryption means that an attacker who intercepts the transmission cannot understand the data without the key. Asymmetric encryption can be used to securely establish/share a key, while symmetric encryption can then efficiently protect the actual communication.

Hashing is different from encryption. Hashing is a one-way process that converts data into a fixed-length hash value. The original data should be practically impossible to obtain from the hash. Therefore, hashing is suitable for information that does not needto be retrieved in its original form, such as the robot's users' passwords.

For example, instead of storing a user's password, the robot could store its hash. When the user enters their password, the robot hashes the entered password and compares the result with the stored hash. If the hashes match, the password is considered correct. If an attacker steals the stored hashes, they cannot simply decrypt them to obtain the original passwords.

Hashing can also be used to check whether data has been changed or corrupted, because changing the input produces a different hash.

Therefore, encryption is better for most of the robot's stored data and communications, because the robot needs to be able to recover and use the original data. Hashing is better for passwords and other data that only needs to be verified, because it is one-way.

🧠 The exam-memorytrick:“LOCK vs FINGERPRINT”


🔐 Encryption

#⃣ Hashing

Main purpose

Keep data secret

Check/verify data

Reversible?

Yes

No / one-way

Uses a key?

Yes

No encryption key

Stored passwords?

❌ Not ideal

✅ Ideal

Data the robot needs to read again?

✅ Yes

❌ No

Wireless communication?

✅ Yes

❌ Not for confidentiality

If intercepted

Cannot be understood without key

Hash alone does not provide confidentiality



3
New cards
term image

The customer has to choose between lossy and lossless compression:

  • Lossy permanently removes some data, so the video has a smaller file size but its quality is reduced.

  • Lossless rewrites the data into a more efficient format without losing information, so the original video can be recreated and the original quality ismaintained, but the file size is larger than with lossy compression.

  • With lossy compression, the compression ratio can be adjusted depending on theavailable bandwidth. This can make the video buffer less and start playing quicker, especially on a slower connection, although there may be a noticeable decrease in quality.

  • With lossless compression, more data needs to be streamed, so it can buffer more and take longer to start watching, but the customer gets higher-quality video.


🧠 Easy way toremember:

LOSSY = Less data → Lower quality → Less buffering
LOSSLESS = No data lost → Original quality → More buffering

4
New cards
term image

i. Lossy compression. [1]

ii. Photographs are compressed because it reduces the size of the image file, meaning they use less bandwidth when transmitted and take up less storage space on the web server. [2]


🧠 Memorytrick:“Small → Send → Store”

  • Small = smaller image file

  • Send = less bandwidth needed to send it

  • Store = less storage space on the server


5
New cards
term image

(i) Explain two characteristics of a hashing algorithm. [4 marks]

1. Low chance of collisions: Different files should produce different hashvalues, reducing the risk of twodifferent files being incorrectly identified asduplicates and marked for deletion.

2. Fast to calculate: The hash should be calculated quickly because theprogram needs to process manyfiles. This makes hashing more efficientthan comparing every file bit by bit.

(ii) Explain why apparent duplicateimages might still be present. [2 marks]

Hashing operates on the actual data (bits) in a file, not how the image looks.Two images may look identicalbut have different underlying data, such asdifferent file formats, file sizes or metadata. Therefore, theyproducedifferent hash values and are not identified as duplicates.

Memory trick to remember it

For part (i), remember CFS:

  • C — Collisions should be rare.

  • F — Fast to calculate.

  • S — Smaller output than the original file, making hashes quicker tocompare.

For part (ii), remember “Same appearance ≠ Same bits.”

Two images can look the same but contain different data, so their hashescan differ.



6
New cards
term image

2(a)(i) — 1 mark

The file will download quicker because it has a smaller file size, reducing thetime visitors have to wait.

2(a)(ii) — 3 marks

Lossy compression permanently removes some of the original data, whereaslossless compression reducesthe file size without losing any information.

The organisation should use lossless compression because Shakespeare’soriginal words must bepreserved exactly. Lossy compression could remove or alter characters, making the text inaccurate or unreadable.

Run length encoding (RLE) and dictionary encoding are both lossless compression methods, meaning that the original text can be reconstructed exactly after decompression. However, dictionary encoding is the most suitable method for compressing Shakespeare’s complete works.

Run length encoding works by identifying consecutive occurrences of the same character and replacing them with the character and the number of times it occurs. For example, AAAAABBBCC could be encoded as 5A3B2C. This can reduce the file size when there are many consecutive repeated characters.

However, RLE is unsuitable for Shakespeare’s text because natural language contains very few consecutive repetitions of the same character. In the extract, most characters occur individually, so encoding them with a count could make the compressed file the same size as, or larger than, the original. For example, the consecutive ll in “Shall” and ee in “sweet” would require two characters to represent them, such as 2l and 2e, providing little or no space saving. Therefore, RLE would be ineffective for compressing the complete works.

Dictionary encoding works by creating a dictionary of frequently occurring words or groups of characters and replacing each occurrence with a shorter code or token. The dictionary stores the original words or character groups alongside their codes, allowing the original text to be reconstructed during decompression.

For example, the word “we” could be assigned the token 1, and “Romeo” could be assigned the token 2. Each occurrence could then be replaced by its token, with the dictionary used to restore the original words. Frequently occurring words, such as “the”, “and” and “you”, could also be assigned short tokens. This would reduce the number of characters needed to represent repeated words throughout Shakespeare’s works.

Dictionary encoding is particularly effective for this scenario because the complete works contain many repeated words and groups of characters. Although the dictionary itself requires storage space, the space saved by replacing repeated words throughout a large text file is likely to outweigh this overhead. The larger the text file, the greater the potential benefit from reusing the same tokens.

In conclusion, dictionary encoding is the best choice because Shakespeare’s works contain repeated words and phrases rather than long sequences of identical consecutive characters. RLE would provide little compression and could increase the file size, whereas dictionary encoding can substantially reduce it. Both methods are lossless when implemented correctly, so dictionary encoding would preserve every word, punctuation mark and character while making the file quicker to download and reducing bandwidth usage.

7
New cards
term image

(a) Complete the XOR row [2 marks]

Rule to remember: XOR gives 1 when the bits are different and 0 whenthey are the same.

Text

Text value

Key value

XOR result

O

01001111

01000001 (A)

00001110

C

01000011

01000010 (B)

00000001

R

01010010

01000011 (C)

00010001

Write the final XOR row as:

00001110 00000001 00010001

You get one mark for one byte correct and one mark for all three bytescorrect.

(b) Complete the first and last rows [2 marks]

The first row, labelled (a), is the answer from part (a). The last row is found by XORing that answer with the same key again.

Row

O

C

R

(a)

00001110

00000001

00010001

Key

01000001

01000010

01000011

XOR

01001111

01000011

01010010

Key principle: Applying XOR with the same key twice restores the original data

(Text⊕Key)⊕Key=Text

(c) Symmetric or asymmetric? [2 marks]

Model answer:

The encryption is symmetric because the same key is used to encrypt anddecrypt the data.

(d) Why is asymmetric encryption moresuitable for internet transactions? [4 marks]

Full-mark model answer:

  1. Symmetric encryption requires both parties to have a copy of the samekey.

  2. The key must be shared securely; if it is sent over the internet, an eavesdropper could intercept it.

  3. Asymmetric encryption uses two different keys: a public key and aprivate key.

  4. The public key can be distributed publicly to encrypt data, while the private key is kept secret and issued to decrypt it.


Quick memory trick

XOR

Different = 1, same = 0

Use this rule bit by bit.

Part C

Symmetric = same key

The same key encrypts and decrypts.

Part D

Asymmetric = two keys

Public key is shared; private key is kept secret.

8
New cards