private PasswordValidity ValidateUserPassword(string userPassword) { byte[] paddedPassword = null, password = null; password = Encoding.UTF8.GetBytes(userPassword); Array.Resize(ref password, Math.Min(password.Length, Constants.MaxPasswordSizeV2)); paddedPassword = new byte[password.Length + Constants.SaltLength]; Array.Copy(password, 0, paddedPassword, 0, password.Length); Array.Copy(EncryptionInfo.uValue, Constants.SaltOffset, paddedPassword, password.Length, Constants.SaltLength); byte [] hash = ValidatePassword(paddedPassword); if (arrayMath.ArraysAreEqual(hash, EncryptionInfo.uValue)) { return(PasswordValidity.UserPasswordIsValid); } else { return(PasswordValidity.Invalid); } }