Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

best way to save passwords in SQL server?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jassim Rahma - 27 Aug 2007 17:47 GMT
I want to know what's the best way to save passwords in SQL server using C#?
Nicholas Paldino [.NET/C# MVP] - 27 Aug 2007 18:13 GMT
Jassim,

   Honestly, don't.  Saving passwords is a bad, bad idea.  You are better
off creating a challenge/response mechanism.

   However, if you have to save passwords, then encrypt the column, and
make sure that you secure the encryption key well.  Here is some information
on how to encrypt a column of data:

http://msdn2.microsoft.com/en-us/library/ms179331.aspx

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#?
Iapain - 27 Aug 2007 18:15 GMT
> 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
Chris Shepherd - 27 Aug 2007 19:17 GMT
>> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.