public void LoadSavedWords()
        {
            try
            {
                var dbCon = DBConnection.Instance();
                if (dbCon.IsConnect())
                {
                    UnicodeEncoding          ByteConverter = new UnicodeEncoding();
                    RSACryptoServiceProvider RSA           = new RSACryptoServiceProvider();

                    try
                    {
                        //suppose col0 and col1 are defined as VARCHAR in the DB
                        string q = "CREATE TABLE `words` (`wordsaltedhash` varbinary(767) NOT NULL,`wordasymetricencription` varbinary(767) DEFAULT NULL,`totalcount` int(11) DEFAULT NULL,`wordtxt` varchar(500) DEFAULT NULL,PRIMARY KEY (`wordsaltedhash`)) ENGINE=InnoDB DEFAULT CHARSET=latin1";
                        var    c = new MySqlCommand(q, dbCon.Connection);
                        c.CommandType = CommandType.Text;
                        c.ExecuteNonQuery();
                    }
                    catch
                    {
                    }

                    //suppose col0 and col1 are defined as VARCHAR in the DB
                    string query = "SELECT wordasymetricencription,totalcount,wordtxt FROM words ORDER BY totalcount DESC";
                    var    cmd   = new MySqlCommand(query, dbCon.Connection);
                    cmd.CommandType = CommandType.Text;
                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        String totalcount = "";
                        String txt        = "";
                        try
                        {
                            totalcount = reader["totalcount"].ToString();
                            byte[] wordasymetricencription = (byte[])reader["wordasymetricencription"];
                            txt = reader["wordtxt"].ToString();
                            byte[] decryptedtex = AsymetricDecrypt(wordasymetricencription, RSA.ExportParameters(true), false);
                            // txt = ByteConverter.GetString(decryptedtex);
                        }
                        catch (Exception exp)
                        {
                        }
                        SavedWordsPlaceHolder.Controls.Add(new Literal {
                            Text = "<tr><td>" + txt + "</td><td>" + totalcount + "</td></tr>"
                        });
                    }
                    reader.Close();
                }
                else
                {
                    ErrorPlaceHolder2.Controls.Add(new Literal {
                        Text = "Failed to connect to MYSQL Database, Update the Connection String and try again"
                    });
                }
            }
            catch (Exception exp)
            {
                ErrorPlaceHolder2.Controls.Add(new Literal {
                    Text = exp.Message
                });
            }
        }
        public void SaveWordResult(List <KeyValuePair <string, int> > pairList)
        {
            var dbCon = DBConnection.Instance();

            if (dbCon.IsConnect())
            {
                UnicodeEncoding ByteConverter = new UnicodeEncoding();
                int             counter       = 1;
                foreach (KeyValuePair <string, int> pair in pairList)
                {
                    if (counter <= 100)
                    {
                        //   WordsPlaceHolder.Controls.Add(new Literal { Text = " <li class='list-group-item' style='font-size: " + maxfontsize + "%'>" + pair.Key + " : " + pair.Value + "</li>" });
                        byte[] plaintext;

                        byte[] SaltedHash = GenerateSaltedHash(ByteConverter.GetBytes(pair.Key));

                        //suppose col0 and col1 are defined as VARCHAR in the DB
                        string query = "SELECT * FROM words WHERE wordsaltedhash=@SaltedHash";
                        var    cmd   = new MySqlCommand(query, dbCon.Connection);
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@SaltedHash", SaltedHash);

                        var reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            reader.Close();

                            string query2    = "UPDATE words SET totalcount=@totalcount WHERE wordsaltedhash=@wordsaltedhash)";
                            var    insertcmd = new MySqlCommand(query2, dbCon.Connection);
                            insertcmd.CommandType = CommandType.Text;
                            insertcmd.Parameters.AddWithValue("@wordsaltedhash", SaltedHash);
                            insertcmd.Parameters.AddWithValue("@totalcount", pair.Value);
                            insertcmd.ExecuteNonQuery();
                            //update
                        }
                        else
                        {
                            RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
                            plaintext = ByteConverter.GetBytes(pair.Key);
                            byte[] encryptedtext;
                            encryptedtext = AsymetricEncrypt(plaintext, RSA.ExportParameters(false), false);

                            reader.Close();
                            string query2    = "INSERT INTO words(wordsaltedhash,wordasymetricencription,totalcount,wordtxt)VALUES(@wordsaltedhash,@wordasymetricencription,@totalcount,@wordtxt)";
                            var    insertcmd = new MySqlCommand(query2, dbCon.Connection);
                            insertcmd.CommandType = CommandType.Text;
                            insertcmd.Parameters.AddWithValue("@wordsaltedhash", SaltedHash);
                            insertcmd.Parameters.AddWithValue("@wordasymetricencription", encryptedtext);
                            insertcmd.Parameters.AddWithValue("@totalcount", pair.Value);
                            insertcmd.Parameters.AddWithValue("@wordtxt", pair.Key);
                            insertcmd.ExecuteNonQuery();
                        }
                    }
                    else
                    {
                        break;
                    }
                    counter++;
                }

                ErrorPlaceHolder.Controls.Add(new Literal {
                    Text = counter - 1 + " Words Saved Successfully"
                });
            }
            else
            {
                ErrorPlaceHolder.Controls.Add(new Literal {
                    Text = "Words generated but failed to connect to MYSQL Database, Update the Connection String and try again"
                });
            }
        }