Question 14

AQA Computer Science November 2020 Paper 1 (7516/1)AS10 marks

On the specification

14.1
3.1 Fundamentals of programming3.5 Fundamentals of data representation
14.2
3.3 Systematic approach to problem solving
Question text

14 This question refers to the subroutine LoadGreyScaleImage A greyscale image can contain a hidden message, which has been encrypted using a key. The message can be revealed by decrypting the image using the method described below. If an image contains a hidden message, the key to use is the integer value of the digit at the end of the image title in the first line of the file. For example, if the image title is image4 then the key is 4 When decrypting a message from an image file, each greyscale value is used in turn with the key to produce a result. The key is subtracted from the greyscale value and the result is interpreted according to Table 2. Table 2 describes the rules that should be followed to determine what secret character, if any, is hidden in the greyscale image. Table 2 Value of result Interpretation 0 The decrypted character is the space character. > 0 AND ≤ 26 The result is the position in the alphabet of the decrypted character. > 26 The result means that the character was not part of the message that was encrypted, and should be represented by an underscore character, ie the _ character. Example 1 Greyscale value is 1 and the key is 0 1 – 0 = 1 The decrypted character is A as this is the first letter in the alphabet. This should be appended to the hidden message. Example 2 Greyscale value is 5 and the key is 3 5 – 3 = 2 The decrypted character is B as this is the second letter in the alphabet. This should be appended to the hidden message. Example 3 Greyscale value is 7 and the key is 7 7 – 7 = 0 The decrypted character is a space as the result was 0. This should be appended to the hidden message. Example 4 Greyscale value is 52 and the key is 1 52 – 1 = 51 The result is greater than 26 so the greyscale value was not an encrypted character and an underscore character should be added to the hidden message. The hidden message is built by concatenating each of the decrypted characters. What you need to do: Task 1 Write a new subroutine, FindSecretChar, which takes as parameters the PixelValue and Key, where Key is the key used to decrypt the hidden character. The subroutine should return the decrypted character if the pixel value was a character from the message, otherwise it should return the underscore character. Task 2 Amend the subroutine LoadGreyScaleImage to: • get the key from the image title • call the subroutine FindSecretChar in the appropriate place and build up the hidden message from the returned characters • output the complete hidden message. Task 3 Test that the changes you have made work by conducting the following test: • run the program • enter L • load greyscale Evidence that you need to provide Include the following evidence in your Electronic Answer Document. 14.1 Your PROGRAM SOURCE CODE for the entire subroutines FindSecretChar and LoadGreyScaleImage [9 marks] 14.2 SCREEN CAPTURE(S) showing the requested test, including the display of the message and the image. [1 mark]