Lecture 57

posted May 14, 2013, 6:59 AM by Samuel Konstantinovich   [ updated May 14, 2013, 12:43 PM ]
You will probably want to use MD5:
Basic example: (You need to incorporate this into your code so test it out)
    import md5                                #this is required for any md5 command
    password="getsomepassword"     #you probably want to get the password from the form
    m=md5.new()                             #this initializes the md5
    m.update(password)                    #this puts the password into the md5
    hashedpass=str(m.hexdigest())    #this makes the encrypted password and stores it into hashedpass
    print hashedpass                        #you don't want to print it, but you can use this to test the code.

A. Account creation:
1. Create a form in create.html that opens create.py
-name
-email
-password *password field*
submit (create account)

2. Make an empty plain text data file in your home directory, then change the permissions with chmod: chmod 666 filename , to give it read/write permissions. This file will be used to store your password information.

3. Make the file to receive your form. Create.py will append to that file you created in your home dir.  '../thefileyoumade'  is an example of how you look up 1 directory.
The file should be in the format:

name,email,hashedpassword
name,email,hashedpassword
name,email,hashedpassword

4. Improvements [finish everything before you implement this]:
Make it better by checking for duplicate name/email 
and if you find one, don't append the duplicate. 

B. Login testing:
1. Make a Login form: login.html that opens a py file login.py
-name
-password *password field*
2. Make Login.py which will check if the name is in the password file.
when it finds the name, compare the hashed passwords.
3. If the login is successful display a webpage "login success", 
 otherwise display a webpage "login fail"
4. Improvements [finish everything before you implement this]:
4a. Display a table of all usernames when you log in.
4b. Keep track of how many times they logged in and display that with each username when you log in. (You must write to a new file to keep track of # of times logged in) This is challenging and requires multiple steps. Plan a little before you start it. 

Comments