Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to create HashPaswsord In SP

Author  Topic 

velnias2010
Posting Yak Master

125 Posts

Posted - 2011-07-27 : 11:13:14
Hey so at the moment in my table I have a column called

hash and salt

hash is my Hashpassword of the user entered string and salt

and salt is the single salt value

During user login rather than retreive the salt from DB, create the hashpasword in my code and then compare with hash in DB I am told I can do this straight in my stored procedure.

This is my stored procedure at the moment

ALTER PROCEDURE [dbo].[spCheckMemberLogin] ( @username VARCHAR(100) = default, @hash VARCHAR(100) = default ) AS BEGIN

SET NOCOUNT ON;

SELECT 3 as result, * FROM web_user WHERE (statusId = 1) AND (useremail = @username) AND (hash = @hash)

END

Instead of having
hash = @hash

How can I have

hash = HashBytes('SHA1', salt+user entered password)

where salt should be retrieve from table and user entered password is a variable of the stored procedure

velnias2010
Posting Yak Master

125 Posts

Posted - 2011-07-27 : 11:44:09
Ah got this working

Does that look ok ?

hash = CONVERT(VARCHAR(100),hashbytes('sha1', @hash + salt),2)
Go to Top of Page
   

- Advertisement -