All,
Sorry in advance - I'm a novice in most of the topics below (SQL, ASP). Anyway...
I've got a pretty simple web app that requires users to log in with a user name and password.
The front end creates a salted SHA1 hash of the password, and posts it (along with the user's name) to an ASP page.
That ASP page takes the data, calls a stored procedure in the SQL Server database, and passes the users name and hashed password; the stored procedure writes the info to the 'users' table.
The password column's type in the table is varbinary.
As far as I can tell, when the ASP gets the password (password = Request.Form("password")), it's a String.
I can 'trick' SQL Server into handling it as a varbinary if I create the query this way:
query = "EXEC sp_save_user @username='" & username & "', @password=0x" & password
IOW - I'm prepending an "0x" to the password string.
However, I've read that it's a better practice to use a parameterized query:
E.g.: SET objParam = objCommand.CreateParameter("@password",204, 1, 40, password)
However, this fails because the parameter is supposed to be binary (204), but password is a string.
So, how do I convert a string like "4a5e6a8d521ed487b81c91e131cf27e8dae9b783" to a binary in ASP?
Many thanks in advance!