private void OnChangedItem(object sender, RoutedEventArgs e)
 {
     E = Convert.ToInt32(EList.Text);
     D = RSAController.CalculateD(E, M);
     openedKey.Content = $"<E = {E}, N = {N}>";
     closedKey.Content = $"<D = {D}, N = {N}>";
 }
 private void InitCoeff(object sender, RoutedEventArgs e)
 {
     P = Convert.ToInt32(Pcoeff.Text);
     Q = Convert.ToInt32(Qcoeff.Text);
     M = (P - 1) * (Q - 1);
     N = P * Q;
     EList.ItemsSource = RSAController.CalculateE(M);
 }
        private void encodeClick(object sender, RoutedEventArgs e)
        {
            InputCoeff input1 = new InputCoeff();

            input1.ShowDialog();
            P = Convert.ToInt32(input1.coeffPTextBox.Text);
            Q = Convert.ToInt32(input1.coeffQTextBox.Text);
            M = (P - 1) * (Q - 1);
            N = P * Q;
            E = RSAController.CalculateE(M)[0];
            D = RSAController.CalculateD(E, M);
            contentTextBox.Text = RSAController.Encode(contentTextBox.Text, E, N);
        }
        private static void Main(string[] args)
        {
            string _publicKey = "<RSAKeyValue><Modulus>i6BFZEiowigxEIV/2SUNUTjgslJas0Qe5pqi1qG6CZvyS25ruyZ67FHQw6mSHg22tZ/sfTBWSuS2LU+9QaqVuw==" +
                "</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";

            Console.WriteLine("Please enter the Password you want to have Encrypted: ");

            string passwordPlain = Console.ReadLine();

            string passwordEncrypted = RSAController.Encrypt(passwordPlain, _publicKey);

            Console.WriteLine("");
            Console.WriteLine("Your Encrypted Password is: " + passwordEncrypted);

            string m_exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            try
            {
                using (StreamWriter sw = new StreamWriter(m_exePath + "\\Encrypted.txt", true))
                {
                    sw.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
                    DateTime.Now.ToLongDateString());
                    sw.WriteLine("  ");
                    sw.WriteLine("  {0}", passwordEncrypted);
                    sw.WriteLine("-------------------------------");
                }

                Console.WriteLine("Note: the Password has also been saved into the Encryptet.txt");
            }
            catch (Exception)
            {
            }

            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Pressy Any Key to exit :)");

            Console.ReadKey();
        }
Beispiel #5
0
 public static void clearRSAController()
 {
     rSAController = new RSAController();
 }
 private void decodeClick(object sender, RoutedEventArgs e)
 {
     contentTextBox.Text = RSAController.Decode(contentTextBox.Text, D, N);
 }
 public void TestSetUp()
 {
     controller = new RSAController();
 }