Hillier_Daniel_58243_3522_TextEncryption New

advertisement

Daniel Hillier Text Encryption Wildern School

1

Unit 1

Practical Programming

Python

Text Encryption

2

Документ1

Daniel Hillier Text Encryption Wildern School

Design Solution

The Problem

The problem is a program for text encryption, we are to create a program that will allow the user to ‘encrypt a message’, ‘decrypt a message’ or ‘exit the program’. If the user decides to encrypt a message then it will display a message asking the user to input the file name containing the message to be encrypted, this file will then be encrypted but in a sperate file that contains the encrypted message. If the user decides to decrypt the file then a message will be displayed asking the user to input the name of the file containing the message that the user wants to decrypt.

User Needs

User Menu

Encrypt

Decrypt

Exit

-To be able to encrypt a message.

-To be able to decrypt a message.

-To be able to exit the program.

-To be able to enter a file name that will load the contents of a specified file to be encrypted or decrypted (sample.txt).

-To be able to enter the new text file name so the user will be able to see the finished encryption or decryption in an empty file.

-To be able to enter an 8 character key, previously generated by the program.

-To be able to see the encrypted or decrypted message.

3

Документ1

Daniel Hillier Text Encryption Wildern School

Plan Overview

I will produce/develop a piece of code that will encrypt/decrypt messages. To start of

I will create a menu to allows the user to navigate around the program to encrypt or decrypt messages using if, elif and else. If and when the user selects to encrypt a message they will be asked to enter a new file name (sample.txt) the program will then read the contents of the file ‘sample.txt’ to be encrypted. Next I will create the part of the program that will generate an eight character key that the program will use to encrypt the message this will generate several different random keys (A, B, C, -,},

*, etc.) That will then encrypt the message e.g. “Hello” to “A6B89K,]”. Also I will create the part of the program that will covert each character (A, a, B, b, etc.) into its ASCII code. The user will be asked to enter the name of the text file that they want to be decrypted (sample.txt). The solution will then reads the contents of the specified file that will be decrypted. The programme will then use the eight character key that was entered by the user and use it to decrypt the encrypted message located in the sample.txt file. It will then display the decrypted message to the user on screen.

4

Flowchart

Документ1

Daniel Hillier Text Encryption Wildern School

Документ1

5

Solution Development

Daniel Hillier Text Encryption Wildern School

Документ1

6

Programming Techniques

Daniel Hillier Text Encryption Wildern School

Code Evidence

Print

Int

If

Import

Range

Input

Chr

()

Ord

()

In

Документ1

Explanation

The ‘print’ function will allow the programme to display text to the user.

The ‘int’ statement is a data type, usually associated with whole numbers.

The ‘if’ statement controls what will happen when the user inputs there answer. In my program I have used this in my menu so the user can navigate.

The ‘import’ statement search’s for the stored module by name in the programme.

The ‘range’ function is a versatile function it sets a range for the amount of random generations there will be.

This is used in the part of my programme where it gives the user a randomly generated key from.

The ‘input’ function allows the user to input text/numbers to answer a question or navigate around the program if the input is not valid, a

‘Syntax Error’ will appear (It does not catch user errors!).

The ‘chr’ function converts a whole number to its ASCII equivalent. It is located in the offset part of the programme (Task 3).

The ‘ord’ function converts a letter to its decimal equivalent. Once again it is located in the offset part of the programme.

The ‘in’ statement is combined with the range function and sets a particular target for the random generation. This allows the programm to have a set target and stops at a certain number of regenerations.

Документ1

Daniel Hillier Text Encryption Wildern School

For

From

The ‘for’ statement which repeats a group of statements a specified number of times. You can use any object (such as strings, lists, etc.) in

Python.

The ‘from’ function calls a function form a particular module.

Документ1

Daniel Hillier Text Encryption Wildern School

8

Code

From/Import

Partnership

Daniel Hillier Text Encryption Wildern School

Task

Документ1

9

Explanation

10

Daniel Hillier Text Encryption Wildern School

Code

Документ1

Justification

Daniel Hillier Text Encryption Wildern School

Design of Solution (9 marks)

The problem - 2

User Needs / Success Criteria - 2

Overview Plan - 3

Psuedo Code / Flowchart - 4

Solution Development (Python Program) (9 marks)

Comparison of Solution Against User Needs/ Success Criteria

Solution screenshots with text explaining which Task it addresses

(ensure code is #commented fully to achieve higher marks)

Документ1

Daniel Hillier Text Encryption Wildern School

Programming Techniques (36 marks)

Check Mr Knight's blog for the list of headings

Testing & Evaluation (9 marks)

Test Table to test the success criteria

Show at least one re-test

How well does it meet user need?

What else could you have done to improve the program?

Could you have worked harder on this task?

Документ1

Download