I'm using .Net implementation of BCrypt for storing passwords in the database. The password column is VARCHAR(MAX)
This is the code that updates the Password via stored procedure:
Update [User]
Set [Password]= @NewPassword,
ModifiedOn = GetDate(),
ModifiedBy = 'PasswordChanger'
Where [UserName] = @UserName
For some users, the password gets truncated. An example after truncation is: $2a$12$XM2
This is not the case always.
Please help me understand what could cause the truncation?
UPDATE:
Here is the C# code that calls the SP to update the password:
string HashedPassword;
int NumberOfRowsAffected;
try
{
Database jss = DatabaseFactory.CreateDatabase();
HashedPassword = BCrypt.HashPassword(txtPassword.Text, BCrypt.GenerateSalt(12));
NumberOfRowsAffected = jss.ExecuteNonQuery("procUpdatePassword", GetLogin(HttpContext.Current.User.Identity), HashedPassword);
if (NumberOfRowsAffected > 0)
lblStatus.Text = "Password updated.";
else
{
lblStatus.Text = "Password not updated for this user.";
}
}
catch (Exception ex)
{
lblStatus.Text = "Password was not changed due to an error.";
lblStatus.Text += ex.ToString();
}