Я сейчас занимаюсь разработкой собственного менеджера паролей в c #.
У меня проблема с функцией обновления:
protected internal bool Update()
{
// the updatestring that gets insert into the sqlitecommand
string updatestring = "";
// the affected rows returned by ExecuteNonQuery()
int affectedrows = 0;
try
{
using (SQLiteConnection connection = GetDatabaseConnection())
{
int i = 1;
// looping trough the dictionary that holds the data of the table
foreach (KeyValuePair<string, dynamic> keyValuePair in ArrData)
{
// format the update value e.g: Id = @Id
updatestring += String.Format("{0} = @{1}", keyValuePair.Key, keyValuePair.Key);
// if its not the last value to be updated add a , to the string
if (i < ArrData.Count)
{
updatestring += ", ";
}
i++;
}
connection.Open();
// building the commandtext TableName is set by the child class
SQLiteCommand sqLiteCommand = new SQLiteCommand(String.Format("UPDATE {0} SET ({1})", TableName, updatestring), connection);
sqLiteCommand.CommandType = System.Data.CommandType.Text;
// again looping trough the dictionary to add the parameters to the command
foreach (KeyValuePair<string, dynamic> keyValuePair in ArrData)
{
sqLiteCommand.Parameters.Add(new SQLiteParameter("@" + keyValuePair.Key, keyValuePair.Value));
}
affectedrows = sqLiteCommand.ExecuteNonQuery();
connection.Close();
}
}
catch (SQLiteException ex)
{
MessageBox.Show("Update" + Environment.NewLine + ex.Message);
return false;
}
return affectedrows > 0 ? true : false;
}
Я использую libsodium для шифрования разумных данных.
После шифрования я кодирую байт [] с помощью base64.
Проблема здесь в том, что sqlite не экранирует знак '=' в моих закодированных в base64 переменных.
Выдает ошибку, говорящую, что у меня ошибка логики sql рядом с '='
У вас, ребята, есть разумное решение для такого рода проблем?