Reputation: 16117
I've hashed the password and then I'll insert it to the database but the problem here is that each time I try to do this query this occurs
Cannot implicitly convert type 'string' to 'System.Data.Linq.Binary'
in my table in the database accnt_pass is Binary(50), here's my code
//Instantiate a new Hasher Object
var hasher = new Hasher();
hasher.SaltSize = 16;
//Encrypts The password
var encryptedPassword = hasher.Encrypt(txtPass.Text);
Account newUser = new Account();
newUser.accnt_User = txtUser.Text;
newUser.accnt_Position = txtPosition.Text;
newUser.accnt_Pass = encryptedPassword;
and I am using Encrypto for hashing,
Upvotes: 3
Views: 4736
Reputation: 1665
You need to convert the string encryptedPassword to a byte array if your sql column is of binary type. So instead of the line
newUser.accnt_Pass = encryptedPassword;
put
System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding();
newUser.accnt_Pass = new System.Data.Linq.Binary(encoding.GetBytes(encryptedPassword));
Upvotes: 7