Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.AppSettings.Settings["preset-question"].Value = editPreQues.Text;
            config.AppSettings.Settings["salt1"].Value           = editSalt1.Text;
            config.AppSettings.Settings["salt2"].Value           = editSalt2.Text;
            config.AppSettings.Settings["salt3"].Value           = editSalt3.Text;
            config.AppSettings.Settings["key-hash"].Value        =
                GetHash.hash(GetHash.hash(editPreAns.Text, editSalt1.Text) + editPostStr.Text, editSalt2.Text);
            config.AppSettings.Settings["encrypted-text"].Value = TextEncrypt.encrypt(editText.Text,
                                                                                      GetHash.hash(GetHash.hash(editPreAns.Text, editSalt1.Text) + editPostStr.Text, editSalt3.Text));
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
            File.Copy("key-hash.exe.config", "last-words.exe.config", true);
            MessageBox.Show("已保存");
        }
Example #2
0
        private void btnSpeed_Click(object sender, EventArgs e)
        {
            Stopwatch  sw  = new Stopwatch();
            string     hs  = GetHash.hash("test", editSalt1.Text);
            PostString ps  = new PostString();
            decimal    cnt = 0;

            sw.Start();
            while (true)
            {
                string hs2 = GetHash.hash(hs + ps.toString(), editSalt2.Text);
                cnt++;
                if (sw.ElapsedMilliseconds > 3000)
                {
                    sw.Stop();
                    break;
                }
            }

            speed_          = cnt / (sw.ElapsedMilliseconds / 1000);
            labelSpeed.Text = string.Format("{0} h/s", speed_);
            editPostStr_TextChanged(null, null);
        }