· 9 years ago · Oct 13, 2016, 05:52 AM
1using System;
2
3namespace ConsoleApplication4
4{
5 class Program
6 {
7 static void Main(string[] args)
8 {
9 var p = 3557;
10 var q = 2579;
11 var e = 3;
12 var n = p*q;
13 var fn = (p - 1) * (q - 1);
14 var d = System.Math.Pow(e, -1)%fn;
15 int[] freekey = new int[2] { e, n };
16 double[] secretkey = new double[2] { d, n };
17 Console.WriteLine(" Public key = {" + freekey[0] + "," + freekey[1] + "}");
18 var forCrypt = 111111;
19 var crypted = (System.Math.Pow(forCrypt, e)) % n;
20 Console.WriteLine(" Crypted text = " + Convert.ToString(crypted));
21 Console.ReadKey();
22 }
23 }
24}