Here is an example of using MD5 to validate an encrypted MD5 password from your database during login. This includes salting the password.
Username: test
Password: test
Encypted to look like this: 05a671c66aefea124cc08b76ea6d30bb in the databse.
<!--#include file="md5.asp"-->
<%
'filepath = Server.MapPath(Your Access DB File)
dim filepath
filePath = Server.MapPath("mydir/myfile.mdb")
'PWD set on the access database
PWD = "mypassword"
strConnect = "Provider=MSDASQL;" & _
"DRIVER={Microsoft Access Driver (*.mdb)};"& _
"DBQ=" & filepath & ";" & _
"password=" & PWD & ";"
Dim conn,rs,strsql, form_username, form_password
set conn = server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")
conn.Open AdmConnect
form_username = request.form("username")
form_password = request.form("password")
epassword = form_username + form_password
'parse the password throught the md5.asp file
password = md5(epassword)
strsql = "Select * From tblusers where username = '" & Request.Form("username") & "' and Password = '" & password & "'"
set rs = conn.Execute (strsql)
......
-----------Adding a new record to your user table and encypting and salting the password.
'salt the password before encrypting
strpassword = password + form_username
'salt the password before encypting
strpassword = form_username + form_password
set cn = server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")
cn.Open AdmConnect
rs.open "tblusers", cn, adOpenKeySet, adLockPessimistic, adCmdTable
'add to database
rs.AddNew
rs("username") = form_username
rs("firstname") = form_fname
rs("lastname") = form_lname
rs("email") = form_email
rs("password") = md5(strpassword)
rs("status") = "Active"
rs("authid") = form_permissions
rs.Update
rs.MoveLast
Dim strID
strID = rs("recordid")
For more information MD5 see this site:
http://www.webcheatsheet.com/asp/md...t_passwords.php
You can download the md5.asp file that site as well.
Later we will get into the User requesting there password and allowing them to change it.
Demo will be available soon.