Пример #1
0
        private void CryptoClientForm_Load(object sender, EventArgs e)
        {
            // add algoritams in drop down
            ToolStripMenuItem menu = new ToolStripMenuItem("Algorithams");

            ToolStripMenuItem item = new ToolStripMenuItem("Substitution");
            ICryptoLibrary    alg  = new SimpleSubstitution();

            item.Tag       = alg;
            this.algorithm = alg;
            menu.DropDownItems.Add(item);

            alg      = new XXTEA();
            item     = new ToolStripMenuItem("XXTEA");
            item.Tag = alg;
            menu.DropDownItems.Add(item);

            alg      = new SHA2();
            item     = new ToolStripMenuItem("SHA2");
            item.Tag = alg;
            menu.DropDownItems.Add(item);
            // TODO: add Knapsack

            menu.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.OnClickedItem);
            this.msOptions.Items.Add(menu);


            this.Init();
        }
Пример #2
0
        private void CryptoClientForm_Load(object sender, EventArgs e)
        {
            this.tbSrcPath.Text = ".\\" + this.defaultSrcPath;
            this.tbDstPath.Text = ".\\" + this.defaultDstPath;
            this.defaultSrcPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + this.defaultSrcPath;
            this.defaultDstPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + this.defaultDstPath;

            string[] srcDicFiles = Directory.GetFiles(this.defaultSrcPath);

            foreach (string f in srcDicFiles)
            {
                this.lbFilesToEncrypt.Items.Add(f);
            }

            string[] dstDicFiles = Directory.GetFiles(this.defaultDstPath);

            foreach (string f in dstDicFiles)
            {
                this.lbEncryptedFiles.Items.Add(f);
            }

            this.CreateNewFileWatcher();


            ICryptoLibrary[] algorithams = new ICryptoLibrary[4];
            algorithams[0] = new SimpleSubstitution();
            algorithams[1] = new XXTEA();
            algorithams[2] = new SHA2();
            algorithams[3] = new Knapsack();

            specs = new Dictionary <string, byte[]>();

            // add algoritams in drop down
            ToolStripMenuItem menu = new ToolStripMenuItem("Algorithams");
            ToolStripMenuItem item;

            for (int i = 0; i < algorithams.Length; i++)
            {
                item     = new ToolStripMenuItem(algorithams[i].ToString());
                item.Tag = algorithams[i];
                menu.DropDownItems.Add(item);
                if (i == 0)
                {
                    this.algoritham = algorithams[i];
                }
            }

            menu.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.OnClickedItem);
            this.msOptions.Items.Add(menu);

            this.Init();
            tbN.KeyPress  += this.tbKey_KeyPress;
            tbM.KeyPress  += this.tbKey_KeyPress;
            tbIM.KeyPress += this.tbKey_KeyPress;
            lbHint.Visible = false;
        }