예제 #1
0
        public void RsaStringTest1()
        {
            var rs = new RsaDecrypter(31);
            var rc = new RsaCrypter(rs.OpenKey);

            const string m  = "qwerty";
            var          c  = rc.Crypt(m);
            var          md = rs.Decrypt(c);

            Assert.AreEqual(m, md);
        }
예제 #2
0
        public void RsaRandomTest1()
        {
            var rs = new RsaDecrypter(31);
            var rc = new RsaCrypter(rs.OpenKey);

            var r = new Random();

            for (var i = 0; i < 100; i++)
            {
                var m = new BigInteger(r.Next(1, 10000));
                Assert.AreEqual(m, rs.Decrypt(rc.Crypt(m)));
            }
        }
예제 #3
0
 private void OnEncryptButtonClick(object sender, RoutedEventArgs e)
 {
     try
     {
         TextTextBox.Text =
             RsaDecrypter.Decrypt(CiphertextTextBox.Text
                                  .Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries)
                                  .Select(BigInteger.Parse));
     }
     catch (Exception ex)
     {
         ExceptionMessageBox(ex);
     }
 }