Reputation: 1068
I need to salt and hash some passwords so that I can store them safely in a database. Do you have any advice or ideas as to how best to do this using Linq To SQL?
Upvotes: 10
Views: 1957
Reputation: 433
If it is for user account login you don't want just salt+password hashing, you also want to use key stretching as per PBKDF2 in RFC2898 document.
Here is API to do what you need with example usage: https://sourceforge.net/projects/pwdtknet
Also creates crypto random salt at specified length
Upvotes: 0
Reputation: 25260
Since you are using the .NET and C#, use can use the System.Security.Cryptography.SHA512Managed namespace for generating the salt value and password hash
Upvotes: 3
Reputation: 53310
Basically as @Vojislav says.
You might want to look at bcrypt for the hashing - it's reputed to be very good.
Upvotes: 1
Reputation: 8153
LINQ to SQL doesn't have much relevance in this case. You could use any mechanism you want to, because you won't be doing hashing and salting in SQL.
The steps to save a password would go along these lines:
The steps to verify a password would go along these lines:
Upvotes: 25