I\'m using PBKDF2 in my application to store users passwords. In my Users table, I have a Salt and Password column which is determined like this:>
Casting it directly to a byte[] has worked for me so far.
using (SqlConnection c = new SqlConnection("FOO"))
{
c.Open();
String sql = @"
SELECT Salt, Password
FROM Users
WHERE (Email = @Email)";
using (SqlCommand cmd = new SqlCommand(sql, c))
{
cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = _Email;
using (SqlDataReader d = cmd.ExecuteReader())
{
if (d.Read())
{
byte[] salt = (byte[])d["Salt"];
byte[] pass = (byte[])d["Password"];
//Do stuff with salt and pass
}
else
{
// NO User with email exists
}
}
}
}