Hai All,
Good Evening,
I'm doing a small application using python and MySQL in APPLE MACINTOSH OPERATING SYSTEM. I want to to store the password in encrypted form in the database. While retriving the password it should check the encrypted text with the plain text and it should navigate to the other form.
I have done the encrypted form, but while checking the parameters it should not check the plain text with the encrypted text. It only checks the encrypted text in the database.
This is the code I have given it. Please Check the code and if any modifications please correct it and send to me. -
#! /usr/bin/env python
-
from Tkinter import *
-
import tkMessageBox
-
import Tkinter
-
import time
-
-
-
-
curtime = ''
-
clock = Tkinter.Label(bg="tan")
-
clock.grid(row=22,column=0,columnspan=3,sticky=E)
-
-
def tick():
-
global curtime
-
newtime = time.strftime("TIME:"'%d/%m/%d %H:%M:%S')
-
if newtime != curtime:
-
curtime = newtime
-
clock.config(text=curtime)
-
clock.after(200, tick)
-
-
tick()
-
-
class GUIFramework(Frame):
-
"""This is the GUI"""
-
-
def __init__(self,master=None):
-
"""Initialize yourself"""
-
-
"""Initialise the base class"""
-
Frame.__init__(self,master)
-
-
"""Set the Window Title"""
-
self.master.title("LOGIN FORM")
-
self.master.config(bg="wheat")
-
"""Display the main window"
-
with a little bit of padding"""
-
self.grid(padx=10,pady=10)
-
self.CreateWidgets()
-
-
def CreateWidgets(self):
-
"""Create all the widgets that we need"""
-
self.config(bg="wheat")
-
self.lbText = Label(self,text="LOGIN DETAILS",bg="tan",relief="solid")
-
self.lbText.grid(row=0, column=0,sticky=NSEW,columnspan=50,pady=10)
-
-
"""Create the Text"""
-
self.lbText1 = Label(self,text="User Name:",bg="wheat",relief="groove",width=20)
-
self.lbText1.grid(row=1, column=0,sticky=W,columnspan=1)
-
-
"""Create the Entry, set it to be a bit wider"""
-
self.enText1 = Entry(self, width=25)
-
self.enText1.grid(row=1, column=1, columnspan=3,sticky=W)
-
-
self.lbText2 = Label(self, text="Password:",bg="wheat",relief="groove",width=20)
-
self.lbText2.grid(row=2, column=0,sticky=W)
-
-
self.enText2 = Entry(self,width=25,show="*")
-
self.enText2.grid(row=2, column=1, columnspan=3,sticky=W)
-
-
self.lbText3 = Label(self, text="Confirm Password:",bg="wheat",relief="groove",width=20)
-
self.lbText3.grid(row=3, column=0,sticky=W)
-
-
self.enText3 = Entry(self,width=25,show="*")
-
self.enText3.grid(row=3, column=1, columnspan=3,sticky=W)
-
-
self.btnsubmit = Button(self, text="Login",command=self.login, bg='wheat',relief="groove",width=8)
-
self.btnsubmit.grid(row=4, column=0,sticky=E,pady=10)
-
-
def login(self):
-
uname=self.enText1.get()
-
pwd=self.enText2.get()
-
cpwd = self.enText3.get()
-
try:
-
import os
-
import MySQLdb
-
import _mysql_exceptions as DB_EXC
-
from hashlib import md5
-
cxn = MySQLdb.connect(user ='root')
-
cur = cxn.cursor()
-
no = cur.execute("insert into abc.users values (%s,%s)", (uname,pwd)) # here abc is the database and users is the table name
-
new = md5
-
st = cur.execute("update abc.users set pwd=MD5(pwd) where uname=%s", (uname))
-
cur.close()
-
cxn.commit()
-
cxn.close()
-
if (no != 0):
-
tkMessageBox.showinfo("Text", "succesfully logged." )
-
else:
-
tkMessageBox.showinfo("Text", "Invalid User Name and password.")
-
except ImportError , e:
-
return None
-
-
if __name__ == "__main__":
-
guiFrame = GUIFramework()
-
guiFrame.mainloop()
Please Check the code and if there are any corrections made it and send to me. It is very urgent.
Please help me.
Thank You in advance.
Warm Regards
Srinivas
6 7008 bvdet 2,851
Recognized Expert Moderator Specialist
Please use code tags. See "How to ask a question" in Posting Guidelines.
Are you having a problem with your code? Do you have a question?
-BV
Moderator
bvdet 2,851
Recognized Expert Moderator Specialist
You can compare the hash value of the plain text to the stored hash value. Here's a simplified example using a dictionary: - import md5
-
-
dd = {'chiller': md5.new('abcdef123').digest(),
-
'hotpants': md5.new('zyx987').digest()}
-
-
def login(self):
-
uname=self.enText1.get()
-
pwd=self.enText2.get()
-
cpwd = self.enText3.get()
-
if pwd == cpwd and dd[uname] == md5.new(pwd).digest():
-
tkMessageBox.showinfo("Text", "Succesfully logged.")
-
self.master.destroy()
-
else:
-
tkMessageBox.showinfo("Text", "Invalid User Name and password.")
Hai,
Good Evening,
I'm doing a small application using python and MySQL. I want to encrypt the password to store in the database and also to decrypt the password while retriving the same password and also to redirect the next form.
While it stores in the database it should be in encrypted form and while accessing the password it should be decrypt it and checks the plain text with the encrypted text and it redirect to the next form.
This is the sample code: - #! /usr/bin/env python
-
from Tkinter import *
-
import tkMessageBox
-
import Tkinter
-
import time
-
-
-
curtime = ''
-
clock = Tkinter.Label(bg="tan")
-
clock.grid(row=22,column=0,columnspan=3,sticky=E)
-
-
def tick():
-
global curtime
-
newtime = time.strftime("TIME:"'%d/%m/%d %H:%M:%S')
-
if newtime != curtime:
-
curtime = newtime
-
clock.config(text=curtime)
-
clock.after(200, tick)
-
-
tick()
-
-
class GUIFramework(Frame):
-
"""This is the GUI"""
-
-
def __init__(self,master=None):
-
"""Initialize yourself"""
-
-
"""Initialise the base class"""
-
Frame.__init__(self,master)
-
-
"""Set the Window Title"""
-
self.master.title("LOGIN FORM")
-
self.master.config(bg="wheat")
-
"""Display the main window"
-
with a little bit of padding"""
-
self.grid(padx=10,pady=10)
-
self.CreateWidgets()
-
-
def CreateWidgets(self):
-
"""Create all the widgets that we need"""
-
self.config(bg="wheat")
-
self.lbText = Label(self,text="LOGIN DETAILS",bg="tan",relief="solid")
-
self.lbText.grid(row=0, column=0,sticky=NSEW,columnspan=50,pady=10)
-
-
"""Create the Text"""
-
self.lbText1 = Label(self,text="User Name:",bg="wheat",relief="groove",width=20)
-
self.lbText1.grid(row=1, column=0,sticky=W,columnspan=1)
-
-
"""Create the Entry, set it to be a bit wider"""
-
self.enText1 = Entry(self, width=25)
-
self.enText1.grid(row=1, column=1, columnspan=3,sticky=W)
-
-
self.lbText2 = Label(self, text="Password:",bg="wheat",relief="groove",width=20)
-
self.lbText2.grid(row=2, column=0,sticky=W)
-
-
self.enText2 = Entry(self,width=25,show="*")
-
self.enText2.grid(row=2, column=1, columnspan=3,sticky=W)
-
-
self.btnsubmit = Button(self, text="Login",command=self.login, bg='wheat',relief="groove",width=8)
-
self.btnsubmit.grid(row=3, column=0,sticky=E,pady=10)
-
-
def login(self):
-
uname=self.enText1.get()
-
pwd=self.enText2.get()
-
try:
-
import os
-
import MySQLdb
-
from hashlib import md5
-
import _mysql_exceptions as DB_EXC
-
cxn = MySQLdb.connect(user ='root')
-
cur = cxn.cursor()
-
pwd= md5(pwd)
-
no = cur.execute("select * from venlabs.users where uname=%s and pwd=%s",(uname,pwd))
-
cur.close()
-
cxn.commit()
-
cxn.close()
-
if (no != 0):
-
tkMessageBox.showinfo("Text", "succesfully logged." )
-
self.master.forward("/invoice1.py")
-
else:
-
tkMessageBox.showinfo("Text", "Invalid User Name and password.")
-
except ImportError , e:
-
return None
-
-
if __name__ == "__main__":
-
guiFrame = GUIFramework()
-
guiFrame.mainloop()
Please help me in this case. I'm struggling from last one month.
Thanks in advance for helping me.
Warm Regards,
Srinivas.
*** Moderator Note ***
This post was moved into an existing thread because it was a double post.
*** Moderator Note ***
Good Evening,
I'm doing a small application using python and mysql. I have encrypted the password using md5. but it is one way process. but I want to encrypt the password before storing into the database and while retriving the values it should be checked the plain text with the encrypted text.
Please help me.
Thanks in advance.
Warm Regards,
Srinivas
bvdet 2,851
Recognized Expert Moderator Specialist @cnivas
Please see post #3 of this thread. Does this information help at all?
-BV
from a security point of view I would suggest SHA1 to hash passwords.
If you want to decrypt the password I would suggest using triple DES, but as you want to decrypt the password you need to store a key somewhere, which everybody could find. Again from a security point of view this is not the best thing to do :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: CLEAR-RCIC |
last post by:
Hello All:
I want to encrypt a username/password inside a config file that will be read
and decrypted by a .dll. I have discovered many ways to do this looking at
Google but was wondering if...
|
by: f_salazar |
last post by:
Im not goo writing in english, so here I go !
Public Shared Function Encriptar(ByVal cleanString As String) As String
Dim clearBytes As ()
clearBytes = New...
|
by: Jason Williard |
last post by:
How would I encrypt a string using MD5?
--
Thank You,
Jason Williard
|
by: Daniel |
last post by:
Hi All,
Does anyone know how to encrypt the password before store in the sql database?
In addition, decrypt the password from database before comparison.
The purpose to do it because to hide the...
|
by: Feng |
last post by:
Hi,
In my project I have a need for encrypting the password portion (only
password, not the whole file) of my database connection string, so the
password doesn't show as plain text. So, basicly,...
| |
by: ghjk |
last post by:
I m developing web base system. I want to add the facility to create users. And could you please tell me how to encrypt their password in mysql database?
|
by: agarwalsunitadhn |
last post by:
hi....
I want to encrypt my password so that no one can view it and in the case of transfer also there is no way to access this one.
In short i want to safely transfer the data through...
|
by: poolboi |
last post by:
hi guys,
i would like to ask thing son encryption of data
presently i'm setting up a mysql database to store usernames and password for authentication
is there ways i can encrypt the column...
|
by: Gilles Ganault |
last post by:
Hello
I'd like to encrypt a customer's organization name to use this as
their password to launch our application, and decrypt it within our
VB5 application.
We will then use this information...
|
by: ghjk |
last post by:
I have to develop a web application using JSP. I'm new to JSP. Could some one tell me how to encrypt password using JSP. I know php.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |