I'm encrypting the text of a passwordbox in my project using SHA256CryptoServiceProvider but when I want to save the encrypted password into my data base (SQL server 2014 management studio) I encounter this error: Validation failed for one or more entities. I've never encountered such error before so I would be appreciated if you help me. Here is my encryption code:
SHA256CryptoServiceProvider sha2 = new SHA256CryptoServiceProvider();
Byte[] B1;
Byte[] B2;
B1 = UTF8Encoding.UTF8.GetBytes(passwordbox.Password.Trim());
B2 = sha2.ComputeHash(B1);
string UserPasswordHashed = BitConverter.ToString(B2);
& here's how I insert it into my SQL table:
wpf1Entities database = new wpf1Entities();
HashedPasswordTable HP = new HashedPasswordTable();
HP.userpass = UserPasswordHashed.ToString();
database.HashedPasswordTable.Add(HP);
database.SaveChanges();