Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            ulong   P   = Convert.ToUInt64(this.textBox1.Text);
            ulong   G   = Convert.ToUInt64(this.textBox2.Text);
            ulong   X   = Convert.ToUInt64(this.textBox3.Text);
            ElGamal ElG = new ElGamal(P, G, X);

            ElG.a = Cypher[0];
            int CypherLength = Cypher.Length - 1;

            ulong[] cypher = new ulong[CypherLength];
            for (int i = 0; i < CypherLength; ++i)
            {
                cypher[i] = Cypher[i + 1];
            }
            ulong[] decypher = ElG.Decryption(cypher);
            this.textBox8.Text = Coding.Decoding(decypher);
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.label5.Visible   = true;
            this.textBox4.Visible = true;
            this.button2.Visible  = true;
            ulong openkey = Convert.ToUInt64(this.textBox1.Text);
            ulong module  = Convert.ToUInt64(this.textBox2.Text);
            RSA   rsa     = new RSA(openkey, "Открытый");

            ulong[] code         = Coding.Encoding(this.textBox3.Text);
            ulong[] cypher       = rsa.Encription(code, module);
            int     CypherLength = cypher.Length;

            for (int i = 0; i < CypherLength; ++i)
            {
                this.textBox4.Text += cypher[i].ToString();
            }
            frm1.Cypher = cypher;
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            ElGamal elG = new ElGamal(P, G, X);
            ulong   K   = elG.GetK();

            ulong[] CodedText = Coding.Encoding(Message);
            ulong   hash      = Hash.GetHash(CodedText, OpenKey, P);
            ulong   a         = ExpByModule.Exponentiation(G, K, P);
            ulong   reverseK  = ExtendedEuclid.FindReverse(K, P - 1);
            ulong   b;

            for (ulong i = 1; ; ++i)
            {
                if (hash == ((X * a + i * K) % (P - 1)))
                {
                    b = i;
                    break;
                }
            }
            ulong[] sign = new ulong[2];
            sign[0]   = a;
            sign[1]   = b;
            Signature = sign;
        }
Esempio n. 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     ulong[] CodedText = Coding.Encoding(this.textBox3.Text);
     this.textBox5.Text = Hash.GetHash(CodedText, Convert.ToUInt64(this.textBox1.Text), Convert.ToUInt64(this.textBox2.Text)).ToString();
 }