Hi everyone. I have an application which uses a SQLite database. In database, I have a table and in one column, I have a value inserted from SQL code which is encrypted with sha1. But, I want to use it in my C# application like this:
OR
But, I understand that I can't use sha1 in SQLite, because it doesn't exists any library for that. But, exists a function that help like this one:
But is not working, I get error at
Error code:
So, I looked for other solution and I found KDF, but I don't really understand how to use it. Can anybody help me with that? It's fine also if manage to encrypt it with sha1.
Code:
cmd.CommandText = "Select * from accounts where (username=@username and password=sha1(@password));";
cmd.Parameters.AddWithValue("@password", password);
OR
Code:
cmd.CommandText = "Select * from accounts where (username=@username and password=@password);";
cmd.Parameters.AddWithValue("@password", sha1(password));
Code:
string sha1(string input) {
byte[] byteArray = Encoding.UTF8.GetBytes(input);
return Convert.ToBase64String(sha1.ComputeHash(byteArray);
}
Code:
sha1.ComputeHash(byteArray);
Code:
sha1(stirng) is a method,which is not valid in the given context