>> I want to know what's the best way to save passwords in SQL server using C#?
>
> Use System.Security.Cryptography and convert password into hashes use
> SHA1/MD5
Note that hashing algorithms are by nature one-way, meaning there isn't
a way to "unhash" something into a password again if you need to
retrieve it. Storing hashes is generally better, but it will mean that
should you ever actually need/want to see the password, you will be
unable to do so (easily, see below).
It used to be that hashes were viewed as offering more security in the
event of a system compromise but that's not necessarily true anymore
with the advent of Rainbow Tables and cheap disk space.
Chris.
Nicholas Paldino [.NET/C# MVP] - 27 Aug 2007 19:27 GMT
Well, if you use a salt value then any attack using rainbow tables is
easily avoided.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
>>> I want to know what's the best way to save passwords in SQL server using
>>> C#?
[quoted text clipped - 13 lines]
>
> Chris.
Chris Shepherd - 27 Aug 2007 19:48 GMT
> Well, if you use a salt value then any attack using rainbow tables is
> easily avoided.
Assuming they didn't already know the algorithm used. Salts do help, but
they don't invalidate rainbow tables -- just those using a different
algorithm to generate hash entries. Any way you slice it a total system
compromise is bad.
Chris.
Jassim Rahma - 28 Aug 2007 20:07 GMT
thsn how can read it?
can you show an example on how to create the passowrd and read it back using
a login textbox?
>>> I want to know what's the best way to save passwords in SQL server using
>>> C#?
[quoted text clipped - 13 lines]
>
> Chris.
Chris Shepherd - 28 Aug 2007 20:34 GMT
> thsn how can read it?
>
> can you show an example on how to create the passowrd and read it back
> using a login textbox?
Nicholas already provided a response on this earlier when he told you
that it was a bad idea to save passwords, but if you absolutely must,
use an encrypted column of data. There's a link in that post that
explains it fairly well.
Chris.
John B - 31 Aug 2007 02:27 GMT
>>>> I want to know what's the best way to save passwords in SQL server
>>>> using C#?
[quoted text clipped - 13 lines]
>>
>> Chris.
> thsn how can read it?
>
> can you show an example on how to create the passowrd and read it back
> using a login textbox?
You would generate a hash of the password they entered in the textbox
and compare it to your stored hash, if they are equal then its the same
password.
Taking care to go through the same salting routine if used.
JB