AQA Computer Science

advertisement
Scenario 4
AQA Computer Science
4512/1 Practical Programming
Jasmine Armstrong
58243
Jasmine Armstrong
4512 Text Encryption
Wildern School
Design of Solution
The Problem:
Encryption is the most effective way to gain data security. To read an encrypted file, you must
have a secret key or password that enables you to decrypt it. Unencrypted data is called plain
text. Decryption is the converting of encrypted text back into its original form, so it can be
understood.
1) The program needs to display a Menu and allow them to choose from encrypt
message, decrypt message and exit the programme.
2) The user needs to asks the program what file to open from the menu - to encrypt
3) Generate and display an 8 character key for the user to see
4) The program needs to calculate the offset
Overview plan:
Task One—


Create a menu involving encryption, decryption and program using ‘print’
Use ‘if’, ‘elif’ and ‘else’ to allow the user to choose their option
Task Two—

Using ‘print’, ask the user to enter their selection
DOCUMENT1
1
Jasmine Armstrong
4512 Text Encryption
Flowchart:
DOCUMENT1
2
Wildern School
Jasmine Armstrong
4512 Text Encryption
Wildern School
Solution Development
Task One:
Print, allows the menu to appear for the user to read:



Encryption
Decryption
Program
‘If’ allows the program determine what choice the user can pick. ‘Elif’ allows there to be more than
one option for the user to choose from. The use of ‘else’ is used when the operator selects
something other than the options.
DOCUMENT1
3
Jasmine Armstrong
4512 Text Encryption
Wildern School
Task 2:
Asks user to:



1: Encrypt
2: Decrypt
3: Exit
Task 3:
Chooses a random variety of numbers and uses ASCII to alter the numbers to its corresponding
letter.
DOCUMENT1
4
Jasmine Armstrong
4512 Text Encryption
Task 4:
Offset changes the character key to a number then divides it by 8 and takes away 32
DOCUMENT1
5
Wildern School
Jasmine Armstrong
4512 Text Encryption
Wildern School
Programming Techniques
TASK 1 MENU
Technique
Print()
Input()
If()
Elif()
Else()
While()
DOCUMENT1
6
Where used and why
To present the menu (1, 2 and 3) on
the computer screen.
Enables the user to type their choice.
Asks whether a condition is true of
false.
Enter choice 1 = encryption
Else = invalid selection
Allows the user to check multiple
expressions for TRUE and perform a
block of code as soon as one of the
conditions evaluates to TRUE.
Enter choice 1 = encryption
Enter choice 2 = decryption
Enter choice 3 = exit
Contains the block of code that
executes if the conditional expression
in the if statement is 0 or a FAULSE
value.
Allows the user to make more than
one decision.
Jasmine Armstrong
4512 Text Encryption
Wildern School
TASK 2 READ FILE
Technique
Where used and why
Print()
Displays the menu (1, 2 and 3) on the
computer screen.
Input()
Enables the user to type their choice.
Open()
Allows the file that the user has
chosen, to open.
Read()
Reads the chosen file and displays it
on the screen.
Def()
Allows the menu to be displayed
after the user makes their choice of
what file they want to open.
TASK 3 GENERATE KEY
Technique
Where used and why
Import random
DOCUMENT1
Transports the random collection of
commands.
Randint
A random variety of numbers.
Range()
The number of times the programme
will loop.
Chr()
Alters a number to a letter, using its
ASCII correspondent.
7
Jasmine Armstrong
4512 Text Encryption
Wildern School
TASK 4 CALCULATE OFFSET
Technique
Where used and why
For()
Int()
Ord()
print()
DOCUMENT1
8
Loops task until finished
Sets to integer
Coverts character to number
Prints “the offset value of the
character key is:”
Jasmine Armstrong
Task
4512 Text Encryption
Wildern School
Data
Structure
Type
Variable
Data Type Purpose
1
Data
Structure
Name
Selection
1
Turn
Variable
Integer
2
2
Filename
Plaintext
Variable
Variable
Integer
Integer
2
File
Variable
Integer
DOCUMENT1
9
Integer
Used to store the choice that
the user entered at the menu
Makes sure you can have
more than one go
Asks you what file to open
The inscription is saved into
this
Reads the file
Jasmine Armstrong
4512 Text Encryption
Data Structures
DOCUMENT1
10
Wildern School
Jasmine Armstrong
4512 Text Encryption
Wildern School
Testing and Evaluation
Test Plan: Task One Menu
Description
Test Data
Welcome
Print Menu
Ask User for
1
Choice
Ask User for
2
Choice
Ask User for
3
Choice
Expected Outcome
Welcome Message is Displayed
Menu Options is Displayed
Display Encryption
Display Decryption
Display Exit Program
Test Table: Task One Menu
Description
Welcome
Print Menu
Test Expected
Actual Outcome
Data Outcome
n/a Welcome
Message is
Displayed
n/a Menu Options
is Displayed
Ask User for 1
Choice
Ask User for 2
Choice
Ask User for 3
Choice
DOCUMENT1
Display
Encryption
Display
Decryption
Display Exit
Program
11
Further
Action
n/a
n/a
n/a
n/a
n/a
Jasmine Armstrong
4512 Text Encryption
Wildern School
Test Table: Task Two Read File
Description Test
Data
Ask for file my_file
name
Expected
Outcome
Open and
print the
file after
menu
choice 1
Actual Outcome
Asks for the file name before displaying the
menu
Print
my_file Open and
contents of
print the
the file
file
Further
Action
Set it as
function so
it appears
once a
choice is
made
n/a
n/a
Test Table: Task Three Generate Key
Description
Return
random
number
Convert
number to
ASCII
Loop return
number 8
times
Add all 8
numbers
together
Print 8
character
key
Test Expected
Data Outcome
n/a Return
random
number
n/a Convert the
number to
ASCII
n/a Loop return
number 8
times
n/a Add all 8 of
the numbers
together
n/a Display an 8
character key
DOCUMENT1
12
Actual Outcome
It did work, a random number was generated
Further
Action
n/a
It did work, the number was converted to
ASCII
n/a
It did work, it created 8 numbers by looping
the programme
n/a
It did work, all 8 numbers were added
together
n/a
n/a
Jasmine Armstrong
4512 Text Encryption
Wildern School
Test Table: Calculate Offset
Description
Test Expected
Data Outcome
DOCUMENT1
Actual Outcome
13
Further
Action
Download