Demo entry 3988510



Submitted by anonymous on Mar 11, 2016 at 10:52
Language: Python 3. Code size: 939 Bytes.

#Login action:
#   The code and database actions performed when the user attempts to log into the system.

import hashlib

from DatabaseInit import *
import SqlDictionary

class User:
    def __init__(self, uid=0): = {} # info to be retrieved from the database
        self.permissions = {}
        self.user_id = uid

        self.dbinterface = UsersInfo()


    def gen_pw_hash(self, password):
        # Create a md5 hash of the password
        phash = hashlib.md5()
        # (Encode the password - the python md5 implementation  only accepts binary data.)
        phash.update(bytes(password, "UTF-8"))
        # return a hexadecimal representation of the md5 hash.
        return phash.hexdigest()

    def password_hash_cmp(self, password_input):
        currenthash =["Password"]
        return currenthash == self.gen_pw_hash(password_input)

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).