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; }
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"); }
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); }