Forum Moderators: mack
<!--#include file="dsn.asp"-->
<%
If Request("Create") <> "" Then
if Len(Request("Admin_Password")) >= 8 Then
If Request("Admin_Password") = Request("Password2") Then
' Generate random salt (10 characters)
Randomize
Salt = ""
For i = 1 to 10
'65 is ASCII for "A"
Salt = Salt & chr(int(Rnd * 26) + 65)
Next' Calculate Hash of (Admin_Password & Salt)
Set CM = Server.CreateObject("Persits.CryptoManager")
Set Context = CM.OpenContext("mycontainer", True)
Set Hash = Context.CreateHash
Hash.AddText Request("Admin_Password") & Salt
HashValue = Hash.Value.Hex
Set Hash = Nothing
Set CM = Nothing
' Save username, hashed value and salt in the database
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open "Settings", "DSN=crypto;UID=sa;PWD=;", 2, 3
RS.addnew
RS("Admin_ID").Value = Request("Admin_ID")
RS("Admin_Password").Value = HashValue
RS("salt").Value = Salt
RS.update
RS.close
Set RS = Nothing
Response.Write "Account was successfully created."
Else
Response.Write "Password was not correctly confirmed."
End If
Else
Response.Write "Password must be at least 8 characters."
End If
End If
%>
<FORM ACTION="AddUser.asp" METHOD="POST">
<TABLE><TR>
<TD>Username:</TD>
<TD><INPUT TYPE="TEXT" NAME="Admin_ID" VALUE="<% = Request("Admin_ID") %>" size="20"></TD>
</TR><TR>
<TD>Password:</TD><TD>
<INPUT TYPE="PASSWORD" NAME="Admin_Password" size="20"></TD>
</TR><TR>
<TD>Confirm Password:</TD>
<TD><INPUT TYPE="PASSWORD" NAME="Password2" size="20"></TD>
</TR><TR>
<TD COLSPAN=2><INPUT TYPE="Submit" NAME="Create" VALUE="Create Account"></TD>
</TR></TABLE></FORM>
<!--#include file="dsn2.asp"-->
Short passwords, and incorrectly confirmed passwords generate the correct rejection statment, so I know it is in the salt generating, or password hashing part of the code. Does anyone have any idea what could be cuasing my error?