Click to See Complete Forum and Search --> : asp/vbscript encrypt password to sql table


kit kalen
01-27-2006, 10:57 PM
Forgive me for my lack of ASP knowledge and for possibly causing some repeated information. I have searched extensively on the subject of encrypting user-entered information to put in a database table, but nothing I do, no code that I've tried, does anything (except produce the ocassional error). I am hoping for someone to hold my hand a little to help me through this problem. Here's the deal (and, again, I apologize if my problem is similar to others' that have been addressed - bear with me):

I have a form that the user fills out. It has fields like username, password, email, address, phone, etc. The action of the form calls an asp page that tests some of the fields for validation (legit email address, username length, etc.) and then enters the data into a table in a SQL Server database. All that works great right now. However, in addition to this, I want to encrypt the password field contents before it is entered into the database. I have not been able to get this to work. I don't need to be able to de-encrypt the password, although I need people to be able to enter their (un-encrypted) password in order to enter the web site and it be tested against the encrypted one in the database. I don't know how to go about doing this, and I'm not a fabulous ASP coder. Any help would be fantastic. Thanks.

russell_g_1
01-28-2006, 09:15 AM
ok. assuming you want the hashing done in asp...

just do a search on google for an algorithm like md5. i just tried it and found an example of one. its probably sensible to put this in its own include file.

then you need to add it into your saving code. this should be as simple as saying
hashpwd = md5(origpassword)
and then putting it into the db however you like, i.e. create an sql statement or use a recordset.

the login part is the same. you just need to compare the two hashed passwords, one from the db and one that the user just entered. if they match then in they go...

hope that helps a bit :)

chrismartz
01-28-2006, 09:51 AM
You could also use SQL's built in password encryption for your application. Just search for PWDENCRYPT for MSSQL.

kit kalen
01-28-2006, 12:25 PM
I'm very appreciative. Thank you. I got it to work and I think I'm on my way. Thanks for steering me in a couple fruitful directions!