Exemplo n.º 1
0
 private void btnRsaKey_Click(object sender, EventArgs e)
 {
     // Cryptography.GenRSAKeyPair(out publicKey, out privateKey, 384);
     (string publicKey, string privateKey) = RSAHelper.GenRSAKeyPair();
     txt72.Text = publicKey;
     txt73.Text = privateKey;
 }
Exemplo n.º 2
0
        public void RsaCryptTest()
        {
            (string pubKey, string priKey) = RSAHelper.GenRSAKeyPair();
            Console.WriteLine(pubKey);
            Console.WriteLine(priKey);

            string encyypted = RSAHelper.EncryptString(pubKey, "testsetsetset");

            Console.WriteLine(encyypted);

            var decrypt = RSAHelper.DecryptString(priKey, encyypted);

            Assert.IsTrue(decrypt == "testsetsetset");
        }
Exemplo n.º 3
0
        public void RsaSignTest()
        {
            (string pubKey, string priKey) = RSAHelper.GenRSAKeyPair();
            Console.WriteLine(pubKey);
            Console.WriteLine(priKey);

            string sign = RSAHelper.Sign(priKey, "testsetsetset", HashAlgorithmName.SHA256);

            Console.WriteLine(sign);

            bool signOK = RSAHelper.Verify(pubKey, "testsetsetset", sign, HashAlgorithmName.SHA256);

            Assert.IsTrue(signOK);
        }