May 16, 2005 at 8:15 am
Hi,
We are using the binary form to store the passwords in our project. But we are going into some issues with the binary formats. In other words, let us say my password in binary form, happens to be '0x20161C8Z0D1641'. Say my password field length is 30. Sometimes it stores this as the given binary value for the password and some times it stores it as
'0x20161C8Z0D1641000000000000000000000000000000000000000000000' (i.e, right pads zeroes for the complete length of the field)
With this, if my password is 'abc', when I try to validate it with the stored password, the validation passes for 'abc' as well as most of the strings that start with 'abc', like 'acbcccccc', 'abcaaa' etc.
Is there a way to avoid this problem? Would it work if I change my data type from varbinary to binary or something like that?
Thanks in advance
ourspt
May 16, 2005 at 8:33 am
is the column declared binary of varbinary?
May 16, 2005 at 8:39 am
Right padding ? Something is not right on your app. I can accept that you would have said Left padding but definitely not Right.
Can you double check that?
* Noel
May 17, 2005 at 5:16 am
I can not recreate your problem. The binary code for ABC is different from the binary code for ABCD.
HTH Mike
IF OBJECT_ID('TEMPDB..#TEST') > 0
DROP TABLE #TEST
CREATE TABLE #TEST
(
PK_Test int IDENTITY (1,1) Primary Key,
PW binary (6),
First_Name char(20)
)
INSERT INTO #Test(Pw,First_Name)VALUES(Cast('abc' as binary),'1')
INSERT INTO #Test(Pw,First_Name)VALUES(Cast('abcd' as binary),'2')
INSERT INTO #Test(Pw,First_Name)VALUES(Cast('abcx0' as binary),'3')
SELECT * FROM #Test WHERE PW =CAST('abc' AS BINARY)
May 17, 2005 at 5:36 am
Hi Remi,
The column is declared as varbinary(50) in the database
Thanks
May 17, 2005 at 6:34 am
I would suggest you answer to Noeld's and Michael's question since they know more than me on this topic.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply