Beispiel #1
0
 /*RSA Keylerini generate eder ve hostlara dağıtır
  */
 private void generateRSA_Click(object sender, EventArgs e)
 {
     //Rsa keylerini generate et
     host1 = rsa.generateKey();
     System.Threading.Thread.Sleep(100);
     host2 = rsa.generateKey();
     //view'u refresh et
     refreshKeysinView();
 }
Beispiel #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     //Rsa keylerini generate et
     host1 = rsa.generateKey();
     System.Threading.Thread.Sleep(100);
     host2 = rsa.generateKey();
     //view'u refresh et
     refreshKeysinView();
     //p,q,n,fin bilgilerini yaz
     rsainfo.Text = rsa.ToString();
 }
Beispiel #3
0
        /**RSA public,private anahtar çifti üretir ve hosta verir.**/
        public Host generateKey()
        {
            Host host = new Host(N, FiN);
            //set public key
            BigInteger e = (1 + new Random().Next((int)FiN / 2));
            while (Util.gcd(++e, FiN) != 1) ;//N ile aralarında asal bulana dek arttır
            host.PublicKey = e;//bulunca ata
            //find private key
            BigInteger[] result;
            result = Util.Extended_GCD(FiN, e);
            BigInteger d = result[2];
            if (d < 0)
                d += FiN;
            host.PrivateKey = d;

            if ((d * e) % FiN != 1)
                Console.WriteLine("Keyler Yanlış Üretildi!!! e = "+e+" , d = "+d);

            return host;
        }