Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string password   = txtPassword.Text.Trim();
            string secrectKey = txtSecrectKey.Text.Trim();

            if (string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(secrectKey))
            {
                MessageBox.Show("请输入登录密码和加密密钥!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DateTime now            = DateTime.Now;
            var      initTime       = now.Ticks - openTime.Ticks;
            var      initTimeString = initTime.ToString();

            secrectKey = EncryptUtils.MD5Encrypt(secrectKey);
            var passSecrectKey  = EncryptUtils.GetSecrectKey(initTimeString, secrectKey);
            var encryptPassword = EncryptUtils.DES3Encrypt(password, passSecrectKey);

            RDSDataManager manager = new RDSDataManager();

            manager.SetSecrectKey(secrectKey);
            manager.SetInitTime(initTimeString);
            manager.SetPassword(encryptPassword);
            manager.EncryptServer();

            this.Hide();
            LoginForm loginForm = new LoginForm();

            loginForm.ShowDialog();
            this.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 解密加密的全部密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void decryptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 查询全部数据
            RDSDataManager dataManager = new RDSDataManager();
            var            doc         = dataManager.GetData();
            var            root        = doc.Root;

            RDSDataNode rootNode = new RDSDataNode();

            rootNode.Text             = "远程桌面";
            rootNode.Tag              = Guid.Empty;
            rootNode.NodeType         = RDSDataNodeType.Group;
            rootNode.ContextMenuStrip = rightButtonMenu;
            rootNode.ImageIndex       = 0;

            InitTreeNodes(root, rootNode);

            DecryptPassword(dataManager, rootNode);

            // 清除加密Key和密钥,下次登录需
            dataManager.SetSecrectKey(string.Empty);
            dataManager.SetInitTime(string.Empty);
            dataManager.SetPassword(string.Empty);

            MessageBox.Show("处理成功,请重新启动。", "处理成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }