|
-
Jun 23rd, 2005, 06:37 PM
#1
Thread Starter
PowerPoster
bytes checking/comparing...
hi there.
What I am doing is a bit complicated, well really simple but some aspects of it are complicated.
I am trying to compare a password that is stored in bytes in SQL with a textual password suppled on the form, I can convert that to bytes no problem and gives me the same bytes as the bytes used to store it IN SQL.
the thing is, if the user wants to change the password, I Wanna make sure that the current password supplied meets the same password stored in SQL then i can allow them to change the password successfully.
Now...
since the binary length in SQL of the password field is 50 chars long, its all mainly 0's until the 50th char has been reached (when storing in SQL and when retrieving from SQL)
however, this will not be the case when getting the bytes from a text value/string value, even though the first 8 bytes/sections will be the same - so I cannot do a .equals or a == to compare the 2 values because they will be in different lengths.
how can I solve this problem? any tips/ideas?
Thanks!
-
Jun 23rd, 2005, 09:58 PM
#2
Re: bytes checking/comparing...
hmm I have no idea what's going on, but if I've "guessed" correctly the SQL db reserves 50 bytes for your string password, and after the end of the string all the byte values will be zeros??
You could compare the characters one by one and stop when you hit a 0 in the sql string ha?
or I guess you could try
string pass = System.Text.Encoding.ASCII.GetString ( yourByteArrayHere );
you could remove all the null terminating strings (the 0 byte values) from it:
int pos = pass.IndexOf ("\0");
if (pos!=-1)
pass = pass.Remove (pos, pass.Length-pos);
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jun 24th, 2005, 06:03 AM
#3
Thread Starter
PowerPoster
Re: bytes checking/comparing...
no that will not work because the byte array could have a 0 in it... example:
117
110 //<< here
69
00
00
00
00
..
..
..
-
Jun 24th, 2005, 01:42 PM
#4
Re: bytes checking/comparing...
\0 is an escape character - represents the null terminating character; it should work
-
Jun 24th, 2005, 02:32 PM
#5
Thread Starter
PowerPoster
Re: bytes checking/comparing...
your right... hope that works
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|