Compression, encryption and hashing (1.3.1)
Navigate to resources by choosing units within one of the unit groups shown below.
Delivery guides are designed to represent a body of knowledge about teaching a particular topic and contain:
- Content: A clear outline of the content covered by the delivery guide;
- Thinking Conceptually: Expert guidance on the key concepts involved, common difficulties students may have, approaches to teaching that can help students understand these concepts and how this topic links conceptually to other areas of the subject;
- Thinking Contextually: A range of suggested teaching activities using a variety of themes so that different activities can be selected which best suit particular classes, learning styles or teaching approaches.
a) Lossy vs Lossless compression.
b) Run Length Encoding and dictionary coding for lossless compression.
c) Symmetric and asymmetric encryption.
d) Different uses of hashing.
Approaches to teaching the content
Approaches to teaching the content The overarching theme of this section is the application of algorithms to everyday data processing via the use of patterns. With Lossy vs Lossless compression, learners need to understand that the media that we consume is full of repetitive patterns, eg when 24 frames of video flash by our eyes every second, not everything is changing between the consecutive frames: the background is likely to remain static, so it makes no sense to retransmit it. We can send only the things that have changed and nobody will notice. This is a very common example of lossy compression. Learners often confuse the two, due to them sounding similar to each other. It is important to highlight that the psychological foundations of lossy compression are just as interesting as the algorithms. (A good link is here: File Formats and Compression by JISC Digital Media.)
When discussing Run Length Encoding and dictionary coding, it is important to consider the limitations of both. Run Length is easier to implement in pseudocode and is part of the commonly used JPG image format. Learners should be able to code both algorithms in their choice of a programming language and to process a text of limited length.
Encryption is best demonstrated in practical exercises. Starting with Ceasar cipher might be better for weaker learners, such as those without GCSE Computing experience (where it is discussed in practical assessments). A number of links to free online encryptors and decryptors will help with understanding of what is done to the source text to encrypt it.
A simple example show at Toolz Online.
A more sophisticated example is shown at InfoEncrypt.
Hashing is one of the most common mechanisms for organising data addresses. From storing files on disk, to looking up domain names, to holding passwords; hashing is ubiquitous. It lends itself to a number of practical examples and needs to be contrasted with other ways of organising data.
Common misconceptions or difficulties students may have
The biggest barrier is understanding public and private key encryption (asymmetric). It might take a few lessons to internalise that concept. It is important to consider current affairs in light of Snowden’s revelations and recommendations on the use of encryption for personal communication.
Conceptual links to other areas of the specification – useful ways to approach this topic to set students up for topics later in the course.
There is also a cross-curricular link to Maths through the use of prime numbers for encryption. A good illustration is here: Prime Numbers and Public Key Cryptography by Simon Pampena.
Here is another: Encryption and HUGE numbers narrated by Dr James Grime, published by Numberphile.
There is also a link to Algorithms – the Numberphile video (see previous link) also contains an algorithm for RSA encryption algorithms.
Hashing has strong links both to the Algorithms (such as File System), as well as the Data Protection Act. In random binary files records addressed are calculated using a hashing algorithm often based on transformation of the record’s primary key.
The Data Protection Act holds all collectors of private information to keep the collected data secure, which is accomplished with encryption, amongst other things, like secure physical access or not sending the data outside the EU, etc.
The use of hashing in security is illustrated here: Encoding vs. Encryption vs. Hashing by Daniel Miessler.
It is particularly important for examining whether the data received has been tampered with, which is further explained here: An Illustrated Guide to Cryptographic Hashes (Steve Friedl’s Unixwiz.net) and in the following article: Why salted hash is as good for passwords as for breakfast by William Jackson.
Snippets of Python code from the Interactive Python book will give a practical dimension to the topics in this section. Encryption can be either done through pupilcoded programs or some of the freely available programs, the links to which are provided here.
It might be interesting to get learners to investigate the difference between the HD and SD quality on YouTube. Filming something and putting it up on YouTube will allow learners to compare the quality and comment on the nature of the compression YouTube uses.
An additional topic for advanced pupils might be the use of vector graphics, such as Flash or SVG to keep low file sizes combined with very high image/video quality. This can be contrasted with raster-based formats.
The corresponding chapter in the Interactive Python book is very helpful in getting some practical coding done for the topic. See Hashing resource.
Use Online converter with various settings: zoom in a viewer, describe, pixilation, colours, contrast, shades, file size. Same for sound.
Wired magazine has a good opinion piece on the use of encryption (see resource). The teacher could facilitate a debate with the learners around the issues raised in the article.
A practical exercise on encryption in Python can follow this very detailed (and industry-strength) video Python Encryption Tutorial with PyCrypto by Sentdex (see resource).
If this is too involved, the teacher could give learners a list of 10 numbers ranging between 0 and 100. Using a hash function index=item mod 10, learners could generate a list of addresses that these 10 numbers can be uniquely stored at.
Provide learners with Learner Resource 1 activity sheet so they can investigate the topic of compression.
Provide learners with Learner Resource 2 activity sheet to enable them to explore the different types of encryption.
OCR’s resources are provided to support the teaching of OCR specifications, but in no way constitute an endorsed teaching method that is required by the Board and the decision to use them lies with the individual teacher. Whilst every effort is made to ensure the accuracy of the content, OCR cannot be held responsible for any errors or omissions within these resources. We update our resources on a regular basis, so please check the OCR website to ensure you have the most up to date version.
© OCR 2015 - This resource may be freely copied and distributed, as long as the OCR logo and this message remain intact and OCR is acknowledged as the originator of this work.