Daniel Hillier Text Encryption Wildern School 1 Unit 1 Practical Programming Python Text Encryption 2 Document1 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 Document1 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 Document1 Daniel Hillier Text Encryption Wildern School 5 Document1 Daniel Hillier Text Encryption Wildern School Solution Development 6 Programming Techniques Document1 Daniel Hillier Text Encryption Wildern School Code Evidence Explanation Print The ‘print’ function will allow the programme to display text to the user. Int The ‘int’ statement is a data type, usually associated with whole numbers. If The ‘if’ statement is a follow up from the input function and is a traditional control flow construct. Also known as ‘clean-up code’ it controls what will happen when the user inputs there answer. Import The ‘import’ statement combines two operations; it searches for the named module, then it binds the results of that search to a name in the local scope. Range The ‘range’ function is a versatile function it sets a range for the amount of random generations there will be. Input 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. Chr() Ord() The ‘ord’ function converts a letter to its decimal equivalent. In The ‘in’ statement is combined with the range function and sets a particular target for the random generation. For The ‘for’ statement which repeats a group of statements a specified number of times. You can use any object (such as strings, arrays, lists, tuples, dict and so on) in a for loop in Python. The ‘from’ function calls a function form a particular module. Document1 From Daniel Hillier Text Encryption Wildern School 8 Code From/Import Document1 Partnership Daniel Hillier Text Encryption Wildern School 9 Document1 Daniel Hillier Text Encryption Wildern School 10 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) Document1 Daniel Hillier Text Encryption Wildern School 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) 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? Document1