private string LoadUserBase(out List <User> users, bool single, int id) { users = new List <User>(); SqliteConnection conn = null; SqliteDataReader reader = null; try { conn = new SqliteConnection(@"data source=" + this.UsersFile); conn.Open(); SqliteCommand cmd = new SqliteCommand(conn); cmd.CommandText = "SELECT id, description, fullname, password, securityLevel"; for (int i = 0; i < DBUserShared.FingerCount; ++i) { cmd.CommandText += String.Format(", fingerprint{0}", i); } cmd.CommandText += " FROM User WHERE deleted = 0"; if (single) { cmd.CommandText += " AND id = " + id; } reader = cmd.ExecuteReader(); while (reader.Read()) { Dictionary <int, byte[]> lstFingerPrints = new Dictionary <int, byte[]>(); for (int i = 0; i < DBUserShared.FingerCount; ++i) { byte[] bytes = null; int index = 5 + i; if (!reader.IsDBNull(index)) { try { bytes = DBUserShared.AES_Decrypt((byte[])reader[index]); lstFingerPrints.Add(i, bytes); } catch { //ignore but should not get in here continue; } } } byte[] password = null; if (reader[3] != System.DBNull.Value) { password = (byte[])reader[3]; } User user = new User(int.Parse(reader[0].ToString()), reader[1].ToString(), reader[2].ToString(), password, byte.Parse(reader[4].ToString()), lstFingerPrints); users.Add(user); } return(""); } catch (Exception ex) { return("Error reading user database: " + ex.Message); } finally { if (reader != null) { reader.Close(); reader = null; } if (conn != null) { conn.Close(); conn = null; } } }