I'm trying to store hashes and salts in a database using entity framework. But when I try to call this code to return one of the salts.
var salt = (from u in db.Users
join p in db.Passwords on u.Name equals p.UserName
where u.Name == username
select p.Salt).First();
I get thrown this exception: System.InvalidCastException: 'Unable to cast object of type 'System.String' to type 'System.Byte[]'.'
My Password entity looks like this:
class Password
{
[Key]
public string UserName { get; set; }
public byte[] Hash { get; set; }
public byte[] Salt { get; set; }
public User User{ get; set;}
}
HashandSaltin the passwords table?byte[]in code? LINQ can not magically cast string to byte[]