Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i format my password field into md5 encryption

Status
Not open for further replies.

hex6007

MIS
Sep 2, 2008
53
PH
hello guys,

i created a users table. in the password field, how do i format it to md5? i use the datatype = varchar.
pls help..

thanks in advance
 
use the function HASHBYTES('MD5', 'password goes here')

So, if you have a table of user names and passwords run the update:

UPDATE tUsers SET [Password] = HASHBYTES('MD5', [Password])

This will encode all the password to begin with.

Then, if you have a log in page calling a stored procedure to log the user in and the stored procedure has parameters @Username and @Password, use:

IF EXISTS (SELECT UserID FROM tUsers WHERE Username = @Username AND [Password] = HASHBYTES('MD5', @Password))
' username and password found
ELSE
' username and password not found

I have very recently had this discussion with a customer of mine, and he insisted on us using HASHBYTES for passwords.

I disagreed as this is no more secure than using plain text passwords. I wrote a little loop to query the database on different combinations of HASHBYTES data and I found a password randomly entered by a colleague - unseen to me.
 
wow cool..thanks a lot simon.

now i understand more of this...

best

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top