Tuttlebee_Eliza_58243__text_encryption_CA

advertisement
ELIZA TUTTLEBEE
4512/1 Practical Programming Scenario 4
ELIZA TUTTLEBEE
58234
Eliza Tuttlebee
4512 Encryption
Wildern School
Contents page
Design solution
Solution development
Programming techniques
Data scructure
Testing and evaluating
User needs
1
Eliza Tuttlebee
4512 Encryption
Wildern School
Design of Solution
I have been asked to write a program that uses a randomly-generated key to encrypt the
contents of a text film. The program should also allow the user to decrypt the contents of and
encrypted text file if they provide the correct key. Decryption is the process of converting
encrypted text back into its original form. The encryption method I will use uses character
substitution to encrypt the substitution to encrypt the text. Plain text is the unencrypted text
and cipher text is the encrypted version.
Plaintext
Cipher text
2
Cipher text
Encrypt
Decrypt
Plaintext
Eliza Tuttlebee
4512 Encryption
Wildern School
Flow chart for task 1
This is task 1 it shows what options are for the main menu
Task 1
•
Develop a main menu
Option 1 - encrypt message
Option 2 – decrypt message
Exit the program
3
Eliza Tuttlebee
4512 Encryption
Wildern School
This is task TWO which is showing parts of the program that reads the contents of a text file to be
encrypted.
Task 2
•
Read the Contents of a text file to be encrypted
Ask the user to enter the name of the file containing the message to
be encrypted
Load the contents of the specified file
4
Eliza Tuttlebee
4512 Encryption
Wildern School
Flow chart for task 3
Start
Generate a random integer
between 33 and 126
Repeat 8 times
Convert the random number
into its equivalent ASCII
character
Output file
Task 3
To generate an eight character key the program should:
A.
Generate a random integer between 33 and 126
B.
Convert the random number into its equivalent ASCII
character(For example the number 65 would be converted into the character ‘A’)
C.
key
Repeat steps a and b eight times to generate an eight character
D.
Display the eight character key to user
5
Eliza Tuttlebee
4512 Encryption
Wildern School
Flow chart for task 4
Start
Task 4
Calculate the offset factor based on
the eight character key by
converting each of the eight
characters into its ASCII code,
adding these together, dividing the
result by 8, rounding down to a
whole number and then subtracting
32.
Convert each of its character code
into its ASCII code
Add numbers together
Divide numbers by eight
Round down to a whole number
Subtract 32
6
Offset factor calculated
Eliza Tuttlebee
4512 Encryption
Wildern School
solution development
task 1
This Is the main menu for my
program, which will allow the
user to be able to add text and
have the choice to either encrypt
or decrypt. This main menu
allows the user to choice either
option 1 to encrypt the message
or option 2 to decrypt the
message, or exit the program.
Task 2
This programming allows me to access
files and reads the plaintext file.
Task 3
This task makes an eight
character encrypted message. It
chooses random letters and
random numbers between 33
and 126 to code the message.
task 4
calculates the offset factor based on
the eight character key by converting
each of the eight characters into its
ASCII code, adding these together,
dividing the result by 8, rounding down
to a whole number and subracting 32
7
Eliza Tuttlebee
4512 Encryption
Wildern School
programming techniques and data
Technique used
Explanation
Print ()
The print function in Pyton is a function that
outputs to your console window whatever you
say you want to print out.
Print(“you have chosen to encrypt message”)
If
The If function in pyton is a function that
ecrypts to your console window whatever you
say to encrypt.
if choice == 1:
print ("you've choosen to encrypt message")
The Elif Function in python is a function that
Decrypts to your console window whenever
you say to decrypt.
elif choice == 2:
print ("you've choosen to decrypt message")
The else function in pyton is a function that
givs you a alternative to the if statement.
else:
print ("you must choose 1 or 2")
Elif
Else
Justification
of technique
used
Robustness & efficiency
Data sturcture
8
Task 1
1
Data Structure
Choice
2
Filename
2
2
3
File
Plaintext
Charcater_key
4
Offset
5
Ciphertext
5
Plaintext
Explanation
Saves the user
input(choice 1/2/3)
Save the user
imput(name fime name
Reads file name
Reads file
Saves character key
created
Holds number from
int((total/8))-32
Holds random
encrypted cipher text
Reads file
Eliza Tuttlebee
4512 Encryption
Wildern School
Testing and evaluating
Test no.
9
Description
Test data
1.
Press option
1 on the
main menu.
If choice == 1:
Print
(“you have to
encrypt
message”)
2.
Press option
2 on the
main menu
If choice == 1:
Print
(“decrypt
message”)
3.
Press option
3 on the
main me
If choice == 1:
Print
(“you have
chosen to exit
program”)
Expected
outcome
This should
be printed on
screen if you
select ‘option
1’ (“you have
chosen to
encrypt
message”)
This should
be printed on
screen if you
select ‘option
1’ (“you have
chosen to
decrypt
message”)
This should
be printed on
screen if you
select ‘option
1’ (“you have
chosen to exit
program”)
Actual
outcome
(“you have
chosen to
encrypt
message”)
was printed
on screen
Further
Action?
No works
correctly
(“you have
chosen to
decrypt
message”)
was printed
on screen
No works
correctly
(“you have
chosen to exit
program”)
was printed
on screen
No works
correctly
Eliza Tuttlebee
4512 Encryption
Wildern School
10
Eliza Tuttlebee
4512 Encryption
Wildern School
Technique used
Import
Print()
Read()
If ()
Open ()
While
Input()
Int()
Elif
Else
Isfile()
Ranndint()
Chr()
For
11
Explanation
Justification
of technique
used
Robustness & efficiency
Eliza Tuttlebee
4512 Encryption
Wildern School
12
Eliza Tuttlebee
4512 Encryption
Wildern School
Task
number
1
User need
2
3
4
5
6
13
Did I meet this need?
Develop a main menu
for the program.
yes
Develop the part of the
program that reads the
content of a text file.
Develop the part of the
program that
generates an eight
character key.
Calculate the offset
factor based on the
eight character key by
converting each of the
eight characters.
Develop the part of the
program that converts
each character in the
message into its ASCII
code.
yes
yes
yes
How was this need
met
How could this need be
met?
Download