Question 7
OCR Computer Science June 2017 Paper 1A level15 marks
On the specification
- (a)
- 1.3 Exchanging data
- (b)(i)
- 1.3 Exchanging data
- (b)(ii)
- 1.3 Exchanging data
- (c)
- 1.3 Exchanging data
- (d)
- 1.3 Exchanging data
- (e)
- 2.2 Problem solving and programming1.3 Exchanging data
Question text
7 A web forum stores all its content in a database. (a) The forum stores details of its users in the table called Users. An extract of Users is shown below. userID username passwordHash locked 1 Zeus 8dfa46a79248037752bba6166fcb34f8 1 2 Hera 74d39d60507eb55e000c6ec5c1265891 0 3 Poseidon b015d770d0208ddcce2c2c719fe29371 0 Describe what is meant by the term ‘primary key’, giving an example from the table above. [2] (b) The user’s password is passed to a function that generates a hash and the result is stored in passwordHash. (i) Describe what is meant by the term ‘hash’. [1] (ii) Describe one advantage to storing the password as a hash. [2] (c) Write an SQL statement to get just the passwordHash and locked values of the user Apollo. [3] (d) Sometimes users can have their accounts locked if they behave inappropriately. When this is the case the locked field is set to 1 rather than 0. Write an SQL statement that locks the account of the user Hades [3] (e) The function checkAccess takes in the password the user has entered (givenPassword) along with the password hash (passwordHash) and locked value (locked). passwordHash and locked have already been extracted from the database before being passed to the function. It should return the value true if a user should be allowed access to a system and false if they aren’t. Your function should make use of the pre-written function hash() which takes in a string and returns the hash of that string. e.g. hash("Hello") returns f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 Complete the function checkAccess. function checkAccess(givenPassword, passwordHash, locked) endfunction [4]