php - Searching a HashByte column in MSSQL -
i'm trying search mssql table contains user data. 2 columns interested in username, , password. password column binary(20) datatype , contains data generated by
hashbytes('sha1','password') this call i'm making, without success. missing?
$select_user=sqlsrv_prepare($connection," select id, username dbo.users username=? , password=hashbytes('sha1',?)", array(&$username, &$password));
there nothing in post indicate doing prevent query working.
create table t ( usr varchar(100), pwd binary(20) ); insert t (usr, pwd) values ('john', hashbytes('sha1', 'john-pwd')) insert t (usr, pwd) values ('jane', hashbytes('sha1', 'jane-pwd')) and here sample query:
declare @pwd varchar(100) declare @usr varchar(100) set @usr = 'john' set @pwd = 'john-pwd' -- search john's record username & password select * t usr = @usr , pwd = hashbytes('sha1', @pwd) here sql fiddle link shows working sample: http://sqlfiddle.com/#!6/45766/2/0
usr | pwd ------+---------------------------------------- john | kwrra4hnlawscg4rjmry/9k43sm= you cache hashed password query besides query should work fine.
Comments
Post a Comment