Validate password in store procedure
I'm having trouble with validating an account in the sql server store
procedure. What I do is that I Hashbyte the password of the user. When he
wants to log in into his account I again hashbyte the
parameter(@fPassword) and compare it with the hasbyte password that is in
the database. the problem is that I keep getting a different value.
for example:
declare @fPassword nvarchar(4000)
set @fPassword = 'sharingan1'
IF (CONVERT(NVARCHAR(4000), HASHBYTES('sha1', @fPassword), 1)) <> (select
fPassword from CustomerTable WHERE fUserName = 'cesark14')
BEGIN
print 'b'
END
else
print 'c'
I keep getting 'b'. But when I replace the @fPassword for 'sharingan1', I
get 'c'(which is what I want).
Does anybody know why is the
(CONVERT(NVARCHAR(4000), HASHBYTES('sha1', @fPassword), 1))
where I set @fPassword = 'sharingan1' different than
(CONVERT(NVARCHAR(4000), HASHBYTES('sha1', 'sharingan1'), 1))
No comments:
Post a Comment