I have a problem with the password encryption.
I would like to have the password encrypted like those not highlighted in the picture.
I wrote the following c# code:
SHA1CryptoServiceProvider x = new SHA1CryptoServiceProvider();
//byte[] bs = System.Text.Encoding.Unicode.GetBytes(password);
//byte[] bs = System.Text.Encoding.UTF32.GetBytes(password);
byte[] bs = System.Text.Encoding.UTF8.GetBytes(password);
bs = x.ComputeHash(bs);
var s = new StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
new UserService().ChangeUserPassword(username, s.ToString());
to encrypt the password in the correct way I using the following SQL code that I want remove:
CAST(hashbytes('SHA1',@newuserpassword) as nvarchar)
this is the result:

Looking at the docs for
CONVERT, I suspect you just want:Where 2 is the style which converts to hex without a leading 0x. I suggest you specify the length of the
nvarcharthough, which should be 40 (20 bytes, 2 characters per byte).