Esempio n. 1
0
        public List <BindingIP> GetBindings(bool autoBinded = false)
        {
            DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_DESC, defaultTable, "ID"));

            if (autoBinded)
            {
                dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "AutoBind = 1"));
            }
            List <BindingIP> pwds = new List <BindingIP>();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    BindingIP cmd = new BindingIP()
                    {
                        ID          = dr["ID"].ToSafeInteger(),
                        IPAddress   = SimpleEncryption.Decrypt(dr["IPAddress"].ToSafeString()),
                        Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()),
                        Path        = SimpleEncryption.Decrypt(dr["Path"].ToSafeString()),
                        AutoBind    = dr["AutoBind"].ToSafeInteger(),
                        Code        = dr["Code"].ToSafeString()
                    };
                    pwds.Add(cmd);
                }
            }
            return(pwds);
        }
Esempio n. 2
0
    // Token: 0x06004DB0 RID: 19888 RVA: 0x001A0FBC File Offset: 0x0019F3BC
    public static void SetEncryptedString(string key, string value)
    {
        string str  = SimpleEncryption.EncryptString(key);
        string str2 = SimpleEncryption.EncryptString(value);

        PlayerPrefs.SetString("ENC-" + str, "2" + str2);
    }
Esempio n. 3
0
        public BindingIP GetBinding(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }
            DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "ID=" + id));
            BindingIP b  = new BindingIP();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    try {
                        b = new BindingIP()
                        {
                            ID          = dr["ID"].ToSafeInteger(),
                            IPAddress   = SimpleEncryption.Decrypt(dr["IPAddress"].ToSafeString()),
                            Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()),
                            Path        = SimpleEncryption.Decrypt(dr["Path"].ToSafeString()),
                            AutoBind    = dr["AutoBind"].ToSafeInteger(),
                            Code        = dr["Code"].ToSafeString()
                        };
                    } catch { /*@Ignore exception*/ }
                }
            }
            return(b);
        }
Esempio n. 4
0
    // Token: 0x06004DAE RID: 19886 RVA: 0x001A0F4C File Offset: 0x0019F34C
    public static void SetEncryptedFloat(string key, float value)
    {
        string str  = SimpleEncryption.EncryptString(key);
        string str2 = SimpleEncryption.EncryptFloat(value);

        PlayerPrefs.SetString("ENC-" + str, "0" + str2);
    }
Esempio n. 5
0
    // Token: 0x06004DAF RID: 19887 RVA: 0x001A0F84 File Offset: 0x0019F384
    public static void SetEncryptedInt(string key, int value)
    {
        string str  = SimpleEncryption.EncryptString(key);
        string str2 = SimpleEncryption.EncryptInt(value);

        PlayerPrefs.SetString("ENC-" + str, "1" + str2);
    }
Esempio n. 6
0
        private User ValidateUser(string userName, string password)
        {
            User loggedInUser;

            try
            {
                loggedInUser = db.User.Where(u => u.UserName == userName).FirstOrDefault();

                if (loggedInUser != null)
                {
                    string decryptedPassword = SimpleEncryption.EncryptDecrypt(loggedInUser.Password, ENCYRPTION_KEY);
                    if (decryptedPassword == password)
                    {
                        return(loggedInUser);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                return(null);

                throw e;
            }
        }
        public Credential GetCredential(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }
            DataTable  dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "ID=" + id));
            Credential c  = new Credential();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    try {
                        c = new Credential()
                        {
                            ID          = dr["ID"].ToSafeInteger(),
                            Username    = SimpleEncryption.Decrypt(dr["Username"].ToSafeString()),
                            Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()),
                            PassKey     = SimpleEncryption.Decrypt(dr["PassKey"].ToSafeString()),
                            Code        = dr["Code"].ToSafeString()
                        };
                    } catch { /*@Ignore exception*/ }
                }
            }
            return(c);
        }
Esempio n. 8
0
        private void Setup_Load(object sender, EventArgs e)
        {
            SimpleEncryption decrypt = new SimpleEncryption("password");

            string[] splited = new string[3];
            if (logon_class.Properties.Settings.Default.encrypted.Equals("1"))
            {
                splited               = (decrypt.Decrypt(logon_class.Properties.Settings.Default.db)).Split('=', ';');
                db.Text               = splited[1];
                splited               = (decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog)).Split('=', ';');
                catalog.Text          = splited[1];
                splited               = (decrypt.Decrypt(logon_class.Properties.Settings.Default.security)).Split('=', ';');
                security.SelectedItem = splited[1];
                security.Text         = splited[1];
                splited               = decrypt.Decrypt(logon_class.Properties.Settings.Default.user).Split('=', ';');
                user.Text             = splited[1];
                splited               = decrypt.Decrypt((logon_class.Properties.Settings.Default.password)).Split('=', ';');
                password.Text         = splited[1];
            }
            else
            {
                splited               = (logon_class.Properties.Settings.Default.db).Split('=', ';');
                db.Text               = splited[1];
                splited               = (logon_class.Properties.Settings.Default.catalog).Split('=', ';');
                catalog.Text          = splited[1];
                splited               = (logon_class.Properties.Settings.Default.security).Split('=', ';');
                security.SelectedItem = splited[1];
                security.Text         = splited[1];
                splited               = (logon_class.Properties.Settings.Default.user).Split('=', ';');
                user.Text             = splited[1];
                splited               = (logon_class.Properties.Settings.Default.password).Split('=', ';');
                password.Text         = splited[1];
            }
        }
 /// <summary>
 /// Helper method that can handle any of the encrypted player pref types, returning a float, int or string based
 /// on what type of value has been stored.
 /// </summary>
 public static object GetEncryptedValue(string encryptedKey, string encryptedValue)
 {
     // See what type identifier the encrypted value starts
     if (encryptedValue.StartsWith(VALUE_FLOAT_PREFIX))
     {
         // It's a float, so decrypt it as a float and return the value
         return(GetEncryptedFloat(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else if (encryptedValue.StartsWith(VALUE_INT_PREFIX))
     {
         // It's an int, so decrypt it as an int and return the value
         return(GetEncryptedInt(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else if (encryptedValue.StartsWith(VALUE_STRING_PREFIX))
     {
         // It's a string, so decrypt it as a string and return the value
         return(GetEncryptedString(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else if (encryptedValue.StartsWith(VALUE_BOOL_PREFIX))
     {
         // It's a string, so decrypt it as a string and return the value
         return(GetEncryptedBool(SimpleEncryption.DecryptString(encryptedKey.Substring(KEY_PREFIX.Length))));
     }
     else
     {
         throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
     }
 }
Esempio n. 10
0
        /*{
         *
         *
         *
         *
         *
         *  save.Height = default_time_picker.Height;
         *  string[] splited = new string[3];
         *  splited = (logon_class.Properties.Settings.Default.db).Split('=', ';');
         *  db.Text = splited[1];
         *  splited = (logon_class.Properties.Settings.Default.catalog).Split('=', ';');
         *  catalog.Text = splited[1];
         *  splited = (logon_class.Properties.Settings.Default.security).Split('=', ';');
         *  security.SelectedItem = splited[1];
         *  security.Text = splited[1];
         *  splited = (logon_class.Properties.Settings.Default.user).Split('=', ';');
         *  user.Text = splited[1];
         *  splited = (logon_class.Properties.Settings.Default.password).Split('=', ';');
         *  password.Text = splited[1];
         *  default_time_picker.Text = logon_class.Properties.Settings.Default.default_time;
         * }      */

        private void save_Click_1(object sender, EventArgs e)
        {
            try
            {
                SimpleEncryption encrypt = new SimpleEncryption("password");
                string           sql     = "Data Source=" + db.Text + ";" + "Initial Catalog=" + catalog.Text + ";" + "Persist Security Info=" + security.SelectedItem.ToString() + ";";
                sql += "User ID=" + user.Text + ";" + "Password="******";";
                SqlDataAdapter adapter = new SqlDataAdapter("print '1'", sql);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);
                MessageBox.Show("Изменения сохранены");
                logon_class.Properties.Settings.Default.db        = encrypt.Encrypt("Data Source=" + db.Text + ";");
                logon_class.Properties.Settings.Default.catalog   = encrypt.Encrypt("Initial Catalog=" + catalog.Text + ";");
                logon_class.Properties.Settings.Default.security  = encrypt.Encrypt("Persist Security Info=" + security.Text + ";");
                logon_class.Properties.Settings.Default.user      = encrypt.Encrypt("User ID=" + user.Text + ";");
                logon_class.Properties.Settings.Default.password  = encrypt.Encrypt("Password="******";");
                logon_class.Properties.Settings.Default.encrypted = "1";
                logon_class.Properties.Settings.Default.Save();
                Program.log_write("В настройки logon_agent внесли изменения", EventLogEntryType.Warning);
                this.Setup_Load(sender, e);
            }
            catch (Exception ex)
            {
                Program.log_write("В программе logon_agent произошла ошибка при внесении изменений в настройки \n" + ex.ToString() + "", EventLogEntryType.Error);
                MessageBox.Show("Не удается подключиться к базе данных, проверьте параметры");
            }
        }
Esempio n. 11
0
 public static string DecryptKey(string encryptedKey)
 {
     if (encryptedKey.StartsWith("ENC-"))
     {
         return(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)));
     }
     throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
 }
    /// <summary>
    /// Encrypted version of EditorPrefs.SetBool(), stored key and value is encrypted in player prefs
    /// </summary>
    public static void SetEncryptedBool(string key, bool value)
    {
        string encryptedKey   = SimpleEncryption.EncryptString(key);
        string encryptedValue = SimpleEncryption.EncryptBool(value);

        // Store the encrypted key and value (with relevant identifying prefixes) in PlayerPrefs
        PlayerPrefs.SetString(KEY_PREFIX + encryptedKey, VALUE_BOOL_PREFIX + encryptedValue);
    }
Esempio n. 13
0
        private void Setup_Load(object sender, EventArgs e)
        {
            check_service_state getstate = new check_service_state();
            string cur_service_state     = getstate.get_state("logon_server_service");

            if (cur_service_state.Equals("Running") || cur_service_state.Equals("Starting"))
            {
                service_install_but.Text    = "Удалить сервис";
                service_control_but.Text    = "Остановить сервис";
                service_control_but.Enabled = true;
            }
            else if (cur_service_state.Equals("Not found"))
            {
                service_install_but.Text    = "Установить сервис";
                service_control_but.Enabled = false;
            }
            else
            {
                service_install_but.Text    = "Удалить сервис";
                service_control_but.Text    = "Запустить сервис";
                service_control_but.Enabled = true;
            }
            SimpleEncryption decrypt = new SimpleEncryption("password");

            string[] splited = new string[3];

            if (logon_class.Properties.Settings.Default.encrypted.Equals("1"))
            {
                splited                  = (decrypt.Decrypt(logon_class.Properties.Settings.Default.db)).Split('=', ';');
                db.Text                  = splited[1];
                splited                  = (decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog)).Split('=', ';');
                catalog.Text             = splited[1];
                splited                  = (decrypt.Decrypt(logon_class.Properties.Settings.Default.security)).Split('=', ';');
                security.SelectedItem    = splited[1];
                security.Text            = splited[1];
                splited                  = decrypt.Decrypt(logon_class.Properties.Settings.Default.user).Split('=', ';');
                user.Text                = splited[1];
                splited                  = decrypt.Decrypt((logon_class.Properties.Settings.Default.password)).Split('=', ';');
                password.Text            = splited[1];
                default_time_picker.Text = decrypt.Decrypt(logon_class.Properties.Settings.Default.default_service_time);
            }
            else
            {
                splited                  = (logon_class.Properties.Settings.Default.db).Split('=', ';');
                db.Text                  = splited[1];
                splited                  = (logon_class.Properties.Settings.Default.catalog).Split('=', ';');
                catalog.Text             = splited[1];
                splited                  = (logon_class.Properties.Settings.Default.security).Split('=', ';');
                security.SelectedItem    = splited[1];
                security.Text            = splited[1];
                splited                  = (logon_class.Properties.Settings.Default.user).Split('=', ';');
                user.Text                = splited[1];
                splited                  = (logon_class.Properties.Settings.Default.password).Split('=', ';');
                password.Text            = splited[1];
                default_time_picker.Text = logon_class.Properties.Settings.Default.default_service_time;
            }
        }
Esempio n. 14
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                SimpleEncryption encrypt = new SimpleEncryption("password");

                string sql = "Data Source=" + db.Text + ";" + "Initial Catalog=" + catalog.Text + ";" + "Persist Security Info=" + security.SelectedItem.ToString() + ";";
                sql += "User ID=" + user.Text + ";" + "Password="******";";
                SqlDataAdapter adapter = new SqlDataAdapter("print '1'", sql);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);
                logon_class.Properties.Settings.Default.db       = encrypt.Encrypt("Data Source=" + db.Text + ";");
                logon_class.Properties.Settings.Default.catalog  = encrypt.Encrypt("Initial Catalog=" + catalog.Text + ";");
                logon_class.Properties.Settings.Default.security = encrypt.Encrypt("Persist Security Info=" + security.Text + ";");
                string userstr = "User ID=" + user.Text + ";";
                logon_class.Properties.Settings.Default.user     = encrypt.Encrypt(userstr);
                logon_class.Properties.Settings.Default.password = encrypt.Encrypt("Password="******";");
                if (date.SelectedItem.ToString().Equals("Месяц"))
                {
                    logon_class.Properties.Settings.Default.default_time = encrypt.Encrypt("month");
                }
                else if (date.SelectedItem.ToString().Equals("Неделю"))
                {
                    logon_class.Properties.Settings.Default.default_time = encrypt.Encrypt("week");
                }
                else if (date.SelectedItem.ToString().Equals("День"))
                {
                    logon_class.Properties.Settings.Default.default_time = encrypt.Encrypt("day");
                }
                logon_class.Properties.Settings.Default.encrypted = "1";

                /*
                 * logon_class.Properties.Settings.Default.db = ("Data Source=" + db.Text + ";");
                 * logon_class.Properties.Settings.Default.catalog = ("Initial Catalog=" + catalog.Text + ";");
                 * logon_class.Properties.Settings.Default.security = ("Persist Security Info=" + security.Text + ";");
                 * string userstr = "User ID=" + user.Text + ";";
                 * logon_class.Properties.Settings.Default.user = (userstr);
                 * logon_class.Properties.Settings.Default.password = ("Password="******";");
                 * if (date.SelectedItem.ToString().Equals("Месяц"))
                 *  logon_class.Properties.Settings.Default.default_time = ("month");
                 * else if (date.SelectedItem.ToString().Equals("Неделю"))
                 *  logon_class.Properties.Settings.Default.default_time = ("week");
                 * else if (date.SelectedItem.ToString().Equals("День"))
                 *  logon_class.Properties.Settings.Default.default_time = ("day");
                 * logon_class.Properties.Settings.Default.encrypted = "1";*/
                logon_class.Properties.Settings.Default.Save();
                sql = "exec set_idle_time_for_app @idle_time='" + default_time_picker.Text + "', @workStartTime='" + workStartTime.Text + "', @workEndTime='" + workEndTime.Text + "';";
                logon_class.get_settings.sql_execute(sql);
                MessageBox.Show("Изменения сохранены");
                this.SettingsForm_Load(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Не удается подключиться к базе данных, проверьте параметры\n" + ex.ToString());
            }
        }
Esempio n. 15
0
        public static string GetEncryptedString(string key, string defaultValue = "")
        {
            string str = PlayerPrefs.GetString("ENC-" + SimpleEncryption.EncryptString(key));

            if (!string.IsNullOrEmpty(str))
            {
                return(SimpleEncryption.DecryptString(str.Remove(0, 1)));
            }
            return(defaultValue);
        }
        public void TestEncryptToString()
        {
            string plainText = "Test string Goes Here";

            IEncryption simpleEncryption = new SimpleEncryption();
            string      encryptedText    = simpleEncryption.EncryptToString(plainText);

            //Make sure that the encryption method is making some transformation to the plain text
            Assert.AreNotEqual(plainText, encryptedText);
        }
Esempio n. 17
0
 public void DecryptExampleTests()
 {
     Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("This is a test!", 0));
     Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("hsi  etTi sats!", 1));
     Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("s eT ashi tist!", 2));
     Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt(" Tah itse sits!", 3));
     Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("This is a test!", 4));
     Assert.AreEqual("This is a test!", SimpleEncryption.Decrypt("This is a test!", -1));
     Assert.AreEqual("This kata is very interesting!",
                     SimpleEncryption.Decrypt("hskt svr neetn!Ti aai eyitrsig", 1));
 }
Esempio n. 18
0
 public static void DecodePassword(User user)
 {
     if (user != null && user.UserAuthentications != null)
     {
         var password = user.UserAuthentications.FirstOrDefault(x => x.AuthenticationType == AuthenticationType.Password);
         if (password != null)
         {
             password.AuthenticationData = SimpleEncryption.Decode(password.AuthenticationData);
         }
     }
 }
Esempio n. 19
0
 public static void EncodePassword(User user)
 {
     if (user != null && user.UserAuthentications != null)
     {
         var passwords = user.UserAuthentications.FindAll(x => x.AuthenticationType == AuthenticationType.Password);
         if (passwords.Any())
         {
             passwords.ForEach(x => x.AuthenticationData = SimpleEncryption.Encode(x.AuthenticationData));
         }
     }
 }
Esempio n. 20
0
    // Token: 0x06004DB4 RID: 19892 RVA: 0x001A112C File Offset: 0x0019F52C
    public static string GetEncryptedString(string key, string defaultValue = "")
    {
        string key2 = "ENC-" + SimpleEncryption.EncryptString(key);
        string text = PlayerPrefs.GetString(key2);

        if (!string.IsNullOrEmpty(text))
        {
            text = text.Remove(0, 1);
            return(SimpleEncryption.DecryptString(text));
        }
        return(defaultValue);
    }
        public void TestDecryptSingleCharStringToString()
        {
            IEncryption simpleEncryption = new SimpleEncryption();

            string plainText = "a";

            string encryptedText = simpleEncryption.EncryptToString(plainText);
            string decryptedText = simpleEncryption.Decrypt(encryptedText);

            //Make sure that we are able to get back the same plain text
            Assert.AreEqual(plainText, decryptedText);
        }
 public void Update(Credential c, string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         Dictionary <string, object> data = new Dictionary <string, object>();
         string code = (c.Username + c.Description).RemoveNonAlphaNumeric().ToLower();
         data.Add("Description", SimpleEncryption.Encrypt(c.Description));
         data.Add("Username", SimpleEncryption.Encrypt(c.Username));
         data.Add("PassKey", SimpleEncryption.Encrypt(c.PassKey));
         data.Add("Code", code);
         sqlite.Update(defaultTable, data, "ID", id);
     }
 }
Esempio n. 23
0
        private void InitializeOptions()
        {
            _iconListManager = new IconListManager(imageList16, IconReader.IconSize.Small);

            _cfgs                  = new Configs(BindingFile.DatabaseFile);
            _autoSelectArchi       = _cfgs.Get <bool>("AutoSelectArchitecture");
            _setPassword           = _cfgs.Get <bool>("SetPassword");
            _isShowEnterCmd        = _cfgs.Get <bool>("ShowEnterCmd");
            _isKillProcesses       = _cfgs.Get <bool>("KillProcess");
            _operationalStatusOnly = _cfgs.Get <bool>("OperationalStatus");
            menuToolbar.Checked    = _cfgs.Get <bool>("Toolbar");
            menuStatusbar.Checked  = _cfgs.Get <bool>("Statusbar");
            listViewBind.GridLines = menuGridlines.Checked = _cfgs.Get <bool>("Gridlines");

            int pingCount = _cfgs.Get <int>("PingCount");

            if (pingCount >= 4 && pingCount <= 100)
            {
                _pingCount = pingCount;
            }
            _responseDelay = _cfgs.Get <int>("ResponseDelay");

            Color cmdcolor = _cfgs.Get <Color>("CommandColor");

            if (cmdcolor != null)
            {
                _cmdColor = cmdcolor;
            }
            Font cmdFont = _cfgs.Get <Font>("CommandFont");

            if (cmdFont != null)
            {
                _cmdFont = cmdFont;
            }

            listBoxLog.Font    = _cmdFont;
            menuXPLook.Checked = _cfgs.Get <bool>("XPLook");
            if (menuXPLook.Checked)
            {
                menuStripBind.RenderMode = ToolStripRenderMode.System;
                toolStripBind.RenderMode = ToolStripRenderMode.System;
            }
            else
            {
                menuStripBind.RenderMode = ToolStripRenderMode.Professional;
                toolStripBind.RenderMode = ToolStripRenderMode.Professional;
            }
            _password = _cfgs.Get <string>("MasterPassword");
            _password = SimpleEncryption.Decrypt(_password);
        }
 /// <summary>
 /// Decrypts the specified key
 /// </summary>
 public static string DecryptKey(string encryptedKey)
 {
     if (encryptedKey.StartsWith(KEY_PREFIX))
     {
         // Remove the key prefix from the encrypted key
         string strippedKey = encryptedKey.Substring(KEY_PREFIX.Length);
         // Return the decrypted key
         return(SimpleEncryption.DecryptString(strippedKey));
     }
     else
     {
         throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
     }
 }
Esempio n. 25
0
 private void EncryptBtn_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(InputTextBox.Text))
     {
         var encryptor  = new SimpleEncryption();
         var inputText  = InputTextBox.Text;
         var outputText = encryptor.EncryptText(inputText);
         OutputTextBox.Text = outputText;
     }
     else
     {
         MessageBox.Show("The input field is empty");
     }
 }
Esempio n. 26
0
        static public String GetSqlString()
        {
            SimpleEncryption decrypt = new SimpleEncryption("password");

            if (logon_class.Properties.Settings.Default.encrypted.Equals("1"))
            {
                string connection = decrypt.Decrypt(logon_class.Properties.Settings.Default.db) + decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog) + decrypt.Decrypt(logon_class.Properties.Settings.Default.security) + decrypt.Decrypt(logon_class.Properties.Settings.Default.user) + decrypt.Decrypt(logon_class.Properties.Settings.Default.password);
                return(connection);
            }
            else
            {
                string connection = logon_class.Properties.Settings.Default.db + logon_class.Properties.Settings.Default.catalog + logon_class.Properties.Settings.Default.security + logon_class.Properties.Settings.Default.user + logon_class.Properties.Settings.Default.password;
                return(connection);
            }
        }
Esempio n. 27
0
 public static object GetEncryptedValue(string encryptedKey, string encryptedValue)
 {
     if (encryptedValue.StartsWith("0"))
     {
         return((object)PlayerPrefsUtility.GetEncryptedFloat(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)), 0.0f));
     }
     if (encryptedValue.StartsWith("1"))
     {
         return((object)PlayerPrefsUtility.GetEncryptedInt(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)), 0));
     }
     if (encryptedValue.StartsWith("2"))
     {
         return((object)PlayerPrefsUtility.GetEncryptedString(SimpleEncryption.DecryptString(encryptedKey.Substring("ENC-".Length)), string.Empty));
     }
     throw new InvalidOperationException("Could not decrypt item, no match found in known encrypted key prefixes");
 }
Esempio n. 28
0
 private void SetPassword(string password)
 {
     using (PasswordForm pwd = new PasswordForm(password)) {
         if (pwd.ShowDialog().Equals(DialogResult.OK))
         {
             Cursor.Current = Cursors.WaitCursor;
             _cfgs.Set <string>("MasterPassword", SimpleEncryption.Encrypt(pwd.Password));
             _password      = _cfgs.Get <string>("MasterPassword");
             _password      = SimpleEncryption.Decrypt(_password);
             Cursor.Current = Cursors.Default;
         }
         else
         {
             chkSetPassword.Checked = false;
         }
     }
 }
Esempio n. 29
0
        private void InitOptions()
        {
            _password = _cfgs.Get <string>("MasterPassword");
            if (!string.IsNullOrEmpty(_password))
            {
                try {
                    _password = SimpleEncryption.Decrypt(_password);
                } catch {
                    _password = string.Empty;
                }
                linkChange.Visible = (!string.IsNullOrEmpty(_password));
            }
            int pingCount = _cfgs.Get <int>("PingCount");

            if (pingCount > 0)
            {
                numericUpDownPingCount.Value = pingCount;
            }
            int delay = _cfgs.Get <int>("ResponseDelay");

            if (delay >= 0)
            {
                numericUpDownDelay.Value = delay;
            }
            Color bc = _cfgs.Get <Color>("CommandColor");

            if (bc != null)
            {
                btnColor.BackColor = bc;
                btnColor.Text      = bc.Name;
            }
            Font cf = _cfgs.Get <Font>("CommandFont");

            if (cf != null)
            {
                btnFont.Font = cf;
                btnFont.Text = cf.Name;
            }

            chkAutoSelecteArch.Checked   = _cfgs.Get <bool>("AutoSelectArchitecture");
            chkClearBindList.Checked     = _cfgs.Get <bool>("ClearBindList");
            chkSetPassword.Checked       = _cfgs.Get <bool>("SetPassword");
            chkOperationalStatus.Checked = _cfgs.Get <bool>("OperationalStatus");
            chkEnterCmd.Checked          = _cfgs.Get <bool>("ShowEnterCmd");
            chkKillProcess.Checked       = _cfgs.Get <bool>("KillProcess");
        }
Esempio n. 30
0
        public void get_settings()
        {
            string           check_time = "";
            SimpleEncryption decrypt    = new SimpleEncryption("password");

            if (logon_class.Properties.Settings.Default.encrypted.Equals("1"))
            {
                connection = decrypt.Decrypt(logon_class.Properties.Settings.Default.db) + decrypt.Decrypt(logon_class.Properties.Settings.Default.catalog) + decrypt.Decrypt(logon_class.Properties.Settings.Default.security) + decrypt.Decrypt(logon_class.Properties.Settings.Default.user) + decrypt.Decrypt(logon_class.Properties.Settings.Default.password);
                check_time = decrypt.Decrypt(logon_class.Properties.Settings.Default.default_service_time);
                check_t    = Convert.ToInt32(TimeSpan.Parse(check_time).TotalSeconds) * 1000;
            }
            else
            {
                connection = logon_class.Properties.Settings.Default.db + logon_class.Properties.Settings.Default.catalog + logon_class.Properties.Settings.Default.security + logon_class.Properties.Settings.Default.user + logon_class.Properties.Settings.Default.password;
                check_time = logon_class.Properties.Settings.Default.default_service_time;
                check_t    = Convert.ToInt32(TimeSpan.Parse(check_time).TotalSeconds) * 1000;
            }
        }