Exemplo n.º 1
0
 public string EncryptSHA512(string message)
 {
     using (SHA512 sha512 = SHA512.Create())
     {
         DataBaseData dataBase     = new DataBaseData();
         byte[]       sourcecBytes = Encoding.UTF8.GetBytes(message + pepper + dataBase.Salt);
         Console.WriteLine(dataBase.Salt);
         byte[] hashBytes = sha512.ComputeHash(sourcecBytes);
         string hash      = BitConverter.ToString(hashBytes).Replace("-", String.Empty);
         return(hash);
     }
 }
Exemplo n.º 2
0
        public bool GetDataBaseFile(String filePath)
        {
            bool getDatabase = false;

            try
            {
                // string filePath = OpenDataBaseFile();
                SQLiteConnection connection = new SQLiteConnection(@"DataSource=" + filePath);

                connection.Open();
                string[]            result  = new string[7];
                string[]            result2 = new string[7];
                string              sql     = "select * from user";
                SQLiteCommand       command = new SQLiteCommand(sql, connection);
                SQLiteDataReader    reader  = command.ExecuteReader();
                List <DataBaseData> active  = new List <DataBaseData>();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DataBaseData dataBaseData = new DataBaseData();
                        dataBaseData.UserName = reader[1].ToString();
                        dataBaseData.Password = reader[2].ToString();
                        dataBaseData.Salt     = reader[3].ToString();
                        active.Add(dataBaseData);
                        Console.WriteLine($"{reader[1].ToString()} and {reader[2].ToString()} and {reader[3].ToString()}");
                        getDatabase = true;
                    }
                }
                else
                {
                    Console.WriteLine("No rows found");
                }

                reader.Close();
                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e.Message);
                getDatabase = false;
            }
            return(getDatabase);
        }
Exemplo n.º 3
0
        public bool GetUserData(String filePath)
        {
            try
            {
                SQLiteConnection connection = new SQLiteConnection(@"DataSource=" + filePath);

                connection.Open();
                string[]            result  = new string[7];
                string[]            result2 = new string[7];
                string              sql     = "select * from passwords where ownner='" + DataBase.loginCurrentUser + "'";
                SQLiteCommand       command = new SQLiteCommand(sql, connection);
                SQLiteDataReader    reader  = command.ExecuteReader();
                List <DataBaseData> active  = new List <DataBaseData>();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DataBaseData dataBaseData = new DataBaseData();
                        dataBaseData.UserName = reader[1].ToString();
                        dataBaseData.Password = reader[2].ToString();
                        dataBaseData.Salt     = reader[3].ToString();
                        active.Add(dataBaseData);
                        Console.WriteLine($"{reader[1].ToString()} and {reader[2].ToString()} and {reader[3].ToString()}");
                    }
                    reader.Close();
                    return(true);
                }
                else
                {
                    Console.WriteLine("No rows found");
                    return(false);
                }

                connection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e.Message);
                return(false);
            }
        }