Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb
- from config import Config
- f = file('pymmo.cfg')
- cfg = Config(f)
- sqlHost = cfg.sqlHost
- sqlUser = cfg.sqlUser
- sqlPass = cfg.sqlPass
- dataB = cfg.dataB
- conn = MySQLdb.connect(host = sqlHost,
- user = sqlUser,
- passwd = sqlPass,
- db = dataB)
- cursor = conn.cursor()
- class Admin_Com():
- def __init__(self):
- pass
- def __md5Hash(string):
- md5 = MD5.new()
- md5.update(string)
- md5.update(md5.digest())
- return md5
- def md5Hash_hex(string):
- return __md5Hash(string).hexdigest()
- def newUser(passWord, userName):
- passWord = md5Hash_hex(passWord)
- newUserCommand = 'INSERT into authentication(userName,hash) VALUES(' + "'" + userName +"'" + ',' + "'" + passWord + "'" + ")"
- #cursor.execute(newUserCommand)
- def delUser(userName):
- deleteUserCommand = "DELETE from authentication WHERE userName = " + "'" + userName + "'"
- #cursor.execute(deleteUserCommand)
- def changePass(userName, passWord):
- passWord = md5Hash_hex(passWord)
- changePassCommand = "UPDATE authentication set hash = " + "'" + passWord + "'" + " where userName = " + "'" + userName + "'"
- #cursor.execute(changePassCommand)
- if __name__ == "__main__":
- commands = Admin_Com()
- userName = raw_input("Enter test name: ")
- commands.newUser(userName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement