public void GenerateKeyPair_Test()
        {
            //Default pkcs1 keyPairs
            var keyPairs = RSAHelper.GenerateKeyPair();
            //pkcs1私钥转换成pkcs8
            var pkcs8 = RSAHelper.PKCS1ToPKCS8(keyPairs.PrivateKey);

            Assert.NotEmpty(keyPairs.PrivateKey);
            Assert.NotEmpty(keyPairs.PublicKey);
            Assert.NotEqual(keyPairs.PrivateKey, pkcs8);
        }
        public void Sign_Verify_Test()
        {
            var keypair   = RSAHelper.GenerateKeyPair();
            var signature = RSAHelper.SignDataAsBase64("csharpcode", keypair.PrivateKey);
            var verify    = RSAHelper.VerifyBase64Data("csharpcode", signature, keypair.PublicKey);

            Assert.True(verify);

            var pkcs8      = RSAHelper.PKCS1ToPKCS8(keypair.PrivateKey);
            var signature2 = RSAHelper.SignDataAsBase64("csharpcode", pkcs8, RSAKeyFormat.PKCS8);

            Assert.Equal(signature, signature2);
        }
        public void Encrypt_Dcrypt_Test()
        {
            var keypair = RSAHelper.GenerateKeyPair();

            var encrypted = RSAHelper.EncryptAsBase64("hello", keypair.PublicKey);
            var decrypted = RSAHelper.DecryptFromBase64(encrypted, keypair.PrivateKey);

            Assert.Equal("hello", decrypted);

            //pkcs8密钥
            var pkcs8 = RSAHelper.PKCS1ToPKCS8(keypair.PrivateKey);

            var decrypted2 = RSAHelper.DecryptFromBase64(encrypted, pkcs8, keyFormat: RSAKeyFormat.PKCS8);

            Assert.Equal("hello", decrypted2);
        }