Exemplo n.º 1
0
 private void btnExpand_Click(object sender, EventArgs e)
 {
     ANFEquation eq = new ANFEquation(tbInput.Text);
     //tbOut.Text = eq.ToString();
     eq = (ANFEquation)eq.Expand();
     //tbOut.Text += System.Environment.NewLine + System.Environment.NewLine + eq.ToString();
     tbOut.Text = eq.ToString();
 }
Exemplo n.º 2
0
        private void btnExtract_Click(object sender, EventArgs e)
        {
            ANFEquation eq1 = new ANFEquation(tbOut.Text);
            ANFEquation eq2 = new ANFEquation(tbExtract.Text);

            eq1 = eq1.Extract(eq2);
            tbOut.Text = eq1.ToString();
        }
        public string FullExpand()
        {
            if (encryptedMsg.GetBitState(0) == true)
            {
                string id1 = "".PadLeft(VariableIDLength, '0');
                string id2 = (dataSize).ToString().PadLeft(VariableIDLength, '0');
                for (int i = 0; i < encriptionEqs.Count(); i++)
                {
                    encriptionEqs[i].SubIn(id1, true);
                    encriptionEqs[i].SubIn(id2, true);
                }
            }
            if (encryptedMsg.GetBitState(dataSize * 2 - 2) == true)
            {
                string id1 = (dataSize - 1).ToString().PadLeft(VariableIDLength, '0');
                string id2 = (dataSize * 2 - 1).ToString().PadLeft(VariableIDLength, '0');
                for (int i = 0; i < encriptionEqs.Count(); i++)
                {
                    encriptionEqs[i].SubIn(id1, true);
                    encriptionEqs[i].SubIn(id2, true);
                }
            }

            ANFEquation final = new ANFEquation();

            final.AddAtom(encriptionEqs[0].DeepCopy());

            for (int i = 1; i < dataSize * 2 - 1; i++)
            {
                Minterm mt = new Minterm();
                mt.AddAtom(final);
                mt.AddAtom(encriptionEqs[i].DeepCopy());
                final = (ANFEquation)mt.Expand();
            }

            return final.ToString();
        }