-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Python Project Outline 2.46 |
AS91372: Construct an advanced computer program for a specified task Name: Josh Boag Due: 19th May 2017 |
Problem |
In today’s increasingly connected world there are more and more password and/or usernames required. Many apps and websites require the user to create an account so that they get personalised info or recommendations or the ability to play online with friends. With so many of these types of accounts, remembering login credentials can be quite difficult for some people. |
Task |
To create the first stage of a password safe. This program will store information about the app/website and the password for that place. (Assuming the user always logs into all sites with the same email address.) Users must enter a single combination/pin to unlock the password safe at the start of the program. This program will store all data of website/app and passwords into encrypted in a text file. |
Specifications |
Your password safe must: Ask the user for their name and greet them using their name during the use of their password safe. Ask the user for their email address and their password safe pincode. They will only be allowed into the rest of the program if it these two things match the existing values written in the code. If the email or the pincode does not match what the user has defined then the program will stop running. The pincode should be at least 8 characters long. It must contain at least 1 uppercase, lowercase and number with no spaces. At the start of the program, explain to the user what the program does and give them clear instructions on how to use it Allow the user to choose from the following modes: 1) Find the password for an existing Website/App 2) Add new Website/App and new password for it 3) Change an existing password for an existing Website/App 4) Remove an existing App/Website 5) Account Options 6) Exit Include at least 3 initial websites/apps to start the safe with passwords for these hard coded in your program. Use a file system with each item encrypted. Be tested and debugged |
Constraints |
The password safe should: Follow the algorithm which has been either given to you by your teacher or developed by yourself. Be robust and handle user entries accurately Be created in Python Use good programming practice with relevant and meaningful names of variables, ample comments throughout the program, sensible indenting Use at least one function and at least one indexed data structure (list, dictionary) and be flexible (e.g. use constants and derived values where relevant) Be your own work or, if in pairs, identify clearly the parts which are your own work Be submitted in Google Classroom by the due date which will allow about 3 weeks of in-class time and out-of-class time to complete both the plan and the program. If working in pairs both people need to submit work. |
BrainStorm | |
My goal is to create an advanced encryption based password safe program using only vanilla python (i.e zero external add-ons), in the most efficient way possible. I plan to use txt files to store individual user data.
Ways of achieving this goal are explained below: |
|
Encryption:
Joshua = Otxmzf (Assuming the key is 5) |
Over the summer holidays I experimented with python encryption. I came across ‘caesar cipher’ which can also be know as rotation encryption. It is a substitution cipher where each letter in the original message is replaced with a letter corresponding to a certain number of letters up or down in the alphabet. The diagram left shows the encryption cipher if the number of alphabetical rotation is 3. Similarly, the decryption is the exact same process yet 3 alphabetical rotations backward. The use of this encryption method is to become unreadable to the average reader. This encryption can be turned into a small function in python which can be called at any point in the program. Even spaces get converted into another character. |
File storage:
.txt Text file names will be encrypted |
The items that need to be stored in the file:
Email Address
Pincode
Name
App/Website Name List
App/Website Password list
For my program I have decided to have every user’s data in its own .txt file. I figured this would be more efficient because the number of users on a local computer would be low (Likely to be less than three). Taking this into account, theoretically only a few .txt files will be created. Number of users is equal to number of .txt files. (If I were creating the same program for significantly higher numbers of users on a large database then I would have each set of data in its own text file.1000 users would be equal to 5 .txt files (For each set of data stored)) |
Importing And Exporting:
← Import → Export |
When an existing user logins into the program, the program will read from the users file and import all data into the program. Any changes that are made to the data within the program will be saved and exported into the text file. When the program is run again with the same user login then all previous data will remain. Anything that is saved in the text file will be able to be modified within the program (e.g name will be able to be changed if desired).
All imports will have to be decrypted with a key and all exports will have to be encrypted. This data could be exported after a change is made so it will save if the user closes the program without properly exiting. |
Indexed Data Structures:
2 lists userApps= App1 App2 App3 ↓ ↓ ↓ userPasswords= Pw1 Pw2 Pw3 |
For my indexed data structure I have decided on using two lists. One list will be for storing the strings of the names of Websites/Apps. And the other list will store the strings of the passwords for those Websites/Apps. Both lists will have the have corresponding index. For example, on the diagram to the left, user Apps App1 is equal to userPasswords Pw1.
This makes my program for efficient because it easy to associate an app name with its password. |
Centralized Menu System: | The core component of my program will be a centralized menu system. After login has been successfully completed, the user will be directed to a menu, this menu will include the options that branch off to functions within the program (eg. the option to change/add apps etc). After the user chosen functions are completed then the program will direct the user back to the centralized menu. The number menu will be a numbered menu so the user only has to type the number of the function they would like to go to. |
Variables | |||
Name | Type | Intended Purpose | Scope |
userName | String | Stores the name of the user. | Global |
userEmail | String | User inputs their Email address, saved as string. Must have "@" symbol | Global |
userPincode | String | User inputs their Pincode, saved as string. This will have to be an 8 Character long pincode, It must contain an uppercase letter,a number and a lowercase letter. No spaces will be allowed. | Global |
userApps | List | Stores the strings of the names of the Apps/Websites. Three default apps will be added ('Gmail', 'Code Avengers', 'Python Turtle') | Global |
userPasswords | List | Stores the strings of the passwords of the Apps/Websites. Three default passwords are just ‘Undefined’. | Global |
choice | Dynamic | Name of the variable if any sort of decision needs to be made within the program. (Will become an Integer if required at a number menu or will be converted to a string if a “Yes or No” input is required) | Local |
fileName | (email).txt | Stores the filename of the user's encrypted text file. | Global |
encrypted & decrypted | Strings | Each string with encrypted/decrypted characters | Local |
attempts | Constant Integer | Value of 3. The amount of times a user has the opportunity to input the correct login credentials. | Local |
Input / Output | ||
Name | Type | Reason |
userName | Input/Output | This is an input because when the user creates a new account, the program will ask them to input their name, this data gets stored in a text file. After the account has been created the program will read the file and proceed to print a greeting message (Output) including the user's name. |
userEmail | Input | This input is required to successfully login to the password safe. The user will enter their Email Address. The program will grab and read the text file and verify the email address and then continue to the pincode login.
When the user creates an account, they will also need to input their email address. |
userPincode | Input | After the user has successfully entered a existing email address, they will be required to input their pincode. This will also be stored in the users text file. |
userApps | Input/Output | userApps is an input because the user can add additional apps to the list. The program can also print out the list to display all the app strings (output). |
userPasswords | Input/Output | userPasswords is an input because the user can add additional passwords to the list. The program can also print out the list to display all the password strings (output). |
userChoice | Input | Whenever a decision needs to be made, the user will input to this variable. e.g For a Yes/no question, yes could be entered. (The program will then decide an output) |
Program Based Inputs/Outputs | ||
filename | Input/Output | Using userName, the program will open the users file, read it (Input) and import the strings into their designated variables/lists (output). And output again when the data needs to be exported into the file again. |
writeToFile | Output | This is just a preparation variable, it will take all user data, encrypt it and formulate it into a refined string which will then be written to the users file. (e.g new lines for each piece of information will be added. Commas for all the list items will be added as well) |
attempts | Output | When the user has failed at logging in correctly then the program will close. (3 tries before closure) |
Functions For my program I plan to have multiple functions which link to one another. I want the user to flow freely through my program. | |
Fundamental Functions: Explanation | |
startMenu() | This is the first initial menu when the program is run. The user will have the choice of :
1) Login With existing Account
2) Create new Account
3) Exit
The user will have to input either 1, 2 or 3. Entering 1 will call the login() function. Entering 2 will call the create_account() function and 3 will just end the program.
Error Checking: "choice" will be an Integer in this case, inputting anything else will result in a printed message and the user will get told to input again. |
mainMenu() | After one of the following:
Successful login of an existing user
after the creation of a new account
after a branched function is complete/Returning to menu
The following centralized menu will be printed out:
Each number above will correspond to the following: 1) find_password() 2) addData() 3) change_password() 4) remove_app() 5) account_options() (Not typically necessary**) 6) exportData() and endProgram() Error Checking: “choice” will be an Integer in this case, inputting anything else will result in a printed message and the user will get told to input again. ** - This is just extra code (“Flowery”) which is just added because I can. |
userLogin() | The variables included are userEmail and userPincode. This asks the user to input their existing account credentials. It first asks the user to input their email address, the program will use the built in ‘os’ function to search for a text file with the user's email address. If it is incorrect then the user has 2 more opportunities before the program automatically closes (due to the 3 attempts variable). If the program does find the file then it will only open the file to its second line (where the pincode is held), and ask the user to input the Pin Code. If the Pin Code matches (The file and user inputted) then the login is successful. This then redirects to the menu . Else if the first attempt failed then the user will have two further opportunities or the program closes.
Error Checking: userEmail and userPincode are both strings, instead I opted for 3 attempts basis. userEmail must have an ‘@’ to be able to pass. Verification of the pincode is done when creating or changing the account. |
importData()
NOTE: These strings will be encrypted. For the sake of easy understanding I have explained it this way. |
This takes the existing login data and gets the text file associated and imports the following data: Email Address Pincode Name App/Website Name List App/Website Password list This then grabs each string and assigns it to a variable: userEmail userPincode userName userApps userPasswords Error Checking: There is no user interaction, however a system of checking the layout of the strings may be needed and to make sure the correct amount of strings are there (Checking the file from a previous export that could cause the file to be corrupt). |
exportData()
NOTE: It will have to encrypt each individual string. List items will be encrypted individually and commas will have to be added between each item (this will make it easy for importing since it will read the commas as list items) |
This basically works the same as above but in reverse. This takes the existing user data and gets the text file associated and exports the following variables: userEmail userPincode userName userApps userPasswords It will then layout those variables like this: Email Address Pincode Name App/Website Name List App/Website Password list Error Checking: There is no user interaction, however a system of checking that each variable is able to be written to a file may need to be implemented. E.g no special characters that could mess up a string ”[]’{},() |
passwordFind() | This function will print out the names of the apps:
App: Password:
Gmail *********
Code Avengers *********
Python Turtle *********
The user will then be able to type in the name of the app they would like to find the password for. The user will also be able to type in “all” which will be able to print all the passwords for all the apps.
After input, the program will ask if the user wants to go back to the menu, if yes then return to menu(). If no, then the function will run again.
Error Checking: The program will check that the user's input is in the app name list, else a error message will be printed and the user will have to input again. |
removeApp() | If the user wants to remove an app they will input the name of the app they would like to remove. This will find an index of that list item and then delete the item from userApps and userPasswords. Error Checking: The user will have to type the name of the app else an error message will be printed. |
passwordChange() | This function adds the ability for the user to change a password for an existing app. The user will enter the name of the app they would like to change the password for. The program will get an index and overwrite the string to the password the user has entered. Error Checking: The user must enter the name of an existing app or else an error message will be printed. |
endProgram() | This function will stop the program from running. |
Discrete Functions: (Functions that are used by the program) Explanation | |
encrypt() | This function gets individual strings and rotates each letter through the alphabet X number of times to create an unreadable string which will be stored to a file. |
decrypt() | This function takes encrypted strings and rotates each letter backwards in the alphabet X number of times to create a string that is readable. |
clr() | Clears the python shell. |
Miscellaneous Functions: NOTE: This is flowery extra functionality that has is not needed Explanation | |
account_options(): change_email change_name change_pincode delete_account | This function will add the ability to change account information such as: Email Address Name Pincode Or: Delete the account It will appear to the user as a menu: 1) Change login pincode 2) Change Login Email address 3) Change Display name 4) Delete Account 5) Return to menu The user will enter the number of the function they want. If the user wants to change their credentials then the user will input what they want to change their credentials to. The program will then save those variables to the file. |
Task 4: Testing Plan | ||||
Which input | Value entered | Expected result | Comment | |
userChoice startMenu() | "sdfsdf" | “Please only enter numbers on the menu” | It should be an integer so strings are not allowed | |
choice startMenu() | “1” | Carries on to the if statements and calls the userLogin() function | This is as expected | |
choice menu() | “7” | Repeats the input again | This is good because the number is outside of range | |
Choice menu() | “2” | Is between 1 and 6 so it goes to the if statement = 2 and calls the addData() | This is as expected | |
userEmail login() | “joshgmail” | Should not be accepted because it does not contain a “@”. Input will have to be repeated | This is as expected | |
userEmail login() | “josh.boag@npbhs.school.nz” | This is a valid email so it should be accepted. | This is as expected | |
userPincode createAccount() | “abC123” | This string is only six characters long so it will not be accepted. A error message should pop up “Must be at least 8 characters” | This is expected | |
userPincode createAccount() | “abcDE1234” | This string is more than 8 characters long so it should move on to the next section | This is expected | |
This is a screenshot of my startMenu() Screen with invalid input case. Number outside of menu list String input Special Characters input My program reacts by printing error messages, the user must retry until a valid input is given. This is a screenshot of when an email address is not associated with an account so my program prints “This email address (Wrong Email) does not exist” This works off the fact that the user may have missed or typed the correct characters This is a screenshot of when I added number to the end of my name. The program then printed an error message and I had to retype my input without numbers This is a screenshot of when I tried creating a user with an email account that already existed. |