public void Sign_and_verify_should_sign_with_valid_key_and_verify()
        {
            var    rsa           = new RsaAsymmetricCryptoProvider();
            var    wkFolder      = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.IndexOf("bin"));
            string rsaPrivateKey = @"<RSAKeyValue><Modulus>l7EzMLcKyCWRJGx0llt7ydar6e+ylPvGjmK5NiQ4kNMxfej1KKMamBkuOuNiCoQIivIUsktQ9E+FqGk+oQZN0qx72nzCLVt/WjsZkYxN493tq5phYypZAisGWQIQz2fdpCD66nrZ5a3s7IEZp26iomOt+OZ/BERz/yPDuMgy3YuG2WYmlINR+JCfRKROKCcUw7DwjNnzXSNcx3CvryDvAkQgPZAlu2OihcCR/Ayb7uVDh0GdQ5AFVxKffzHdmG9s0WB86vrpmgnjGV54FMQQpAQ9mN3iO3ItAVudv/S00d9NJp18x4OK6OK/aO1kWqGf5WQmrFUDO9EgO7T8YjlLhw==</Modulus><Exponent>AQAB</Exponent><P>0DN4Etsb4XjIvTjv/GeN1KkJ2hzvSJ1fPAvWOXwAeG7kp275/58SKanLRroSt3s1isJmJ2O+f+9257Voijz0A3b+uG3N1g36DP7ejXQXMrojjrw03JlgyjCmiVw7NDLSxmrR6cmrPOVIXb2u9edaw6ZBH0rx+UhwSYEyv4PfhQU=</P><Q>uoSN6BaOiN6g4+FHRbkfeEodZFMQPkM2oTshmwLxzHIaE1r9GT8gOTc2ukKdooHr3T5IuW9pBNasV2WXIsdahCEgMwoT3WPvYdk7uh2AL5U2CRfiXO1/5gDuZNAjRYPF+u3y/l/IqoMc2Mb+34/QBbn0MSefkV+jSgc/bingdBs=</Q><DP>KQNajexXq6zNbmj+7WvAxrmd1TeJ83X8wqlaQ+yncxH1PP5hhPdi7o4iGwaglUBSJclxsiS17CHR/IcB1ul28A/K0a3ftGEAdvrmAFt0DmwYgQ+WIjacmHfI9poSl4/DcY6tVy6A6vgHr1+kTZCLkqr3fSCYVhDs/a3Tv2JM77k=</DP><DQ>boVxWR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T8YjlLhw==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";

            var signedBites = rsa.Sign(rsaPrivateKey, wkFolder);

            Assert.IsNotEmpty(signedBites);
            Assert.IsTrue(rsa.Verify(rsaPublicKey, signedBites, wkFolder.ConvertToByteArray()));
        }
        public void GenerateKeyPair_generate_key_should_create_two_files_private_and_public_key()
        {
            var    rsa      = new RsaAsymmetricCryptoProvider();
            var    wkFolder = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.IndexOf("bin"));
            string priKey   = Path.Combine(wkFolder, "GenerateKeyPair_generate_key" + "_private.key");
            string pubKey   = Path.Combine(wkFolder, "GenerateKeyPair_generate_key" + "_public.key");

            rsa.GenerateKeyPair(2048, "GenerateKeyPair_generate_key", wkFolder);

            Assert.IsTrue(File.Exists(priKey));
            Assert.IsTrue(File.Exists(pubKey));
        }
        public void encrypt_decrypt_should_not_fail()
        {
            var    test          = "Une idée qu’il a eu à émettre lors du récent forum d’Addis-Abeba autour de la problématique.  Au sujet du contrôle de l’exécutif, des entreprises et services public.";
            var    rsa           = new RsaAsymmetricCryptoProvider();
            var    wkFolder      = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.IndexOf("bin"));
            string rsaPrivateKey = @"<RSAKeyValue><Modulus>vTRSsteV+BZ2Vgs/wSj2LGOrJMNWV91B8lBxN6/D1/kizFai+wT1fZwQfxt4bKFI81XP6BZifAY6tJlE8cOHOhbsQ1X8c37/l3vwhf5VLa9xoco4i7JdEHiHYPbAYlWhATasV5Xn2o1pR3lsXBn+0KEsp5h0pLAL1S0Bo8NDCPFHNwAVAk/XykqKXoqXkLf1RmzPjvCG1GILShvTOx/69HQIJLt9UF3ocl7iPTh08XSN7SEcXjesrVRrO4kmaEpnTXcKltgoXGBI8bZns+9HiBWHtPTGWPvqFDrJL98AhoOjDHwJhKGCyenLUoK5A/oK7j25eS4GOseTopPZqK1gSQ==</Modulus><Exponent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ztEMPS96vxlo4+TVNeLGbFeCQvnl3GzObjf9Nz0NSf6ABM8D5l/W3DaqN9zG+gaNwk32JOJEVsO49krNmBzLAck/tCbNhkHn7R5RrNWHQbA38KqJYcfiRu2ALHaMuygou6DJ+FSbfwelpsOr8huuJYOG/5qDP4EA7kNeuSIqVQ==</D></RSAKeyValue>";
            string rsaPublicKey  = @"<RSAKeyValue><Modulus>vTRSsteV+BZ2Vgs/wSj2LGOrJMNWV91B8lBxN6/D1/kizFai+wT1fZwQfxt4bKFI81XP6BZifAY6tJlE8cOHOhbsQ1X8c37/l3vwhf5VLa9xoco4i7JdEHiHYPbAYlWhATasV5Xn2o1pR3lsXBn+0KEsp5h0pLAL1S0Bo8NDCPFHNwAVAk/XykqKXoqXkLf1RmzPjvCG1GILShvTOx/69HQIJLt9UF3ocl7iPTh08XSN7SEcXjesrVRrO4kmaEpnTXcKltgoXGBI8bZns+9HiBWHtPTGWPvqFDrJL98AhoOjDHwJhKGCyenLUoK5A/oK7j25eS4GOseTopPZqK1gSQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";

            var armoredBytes = rsa.Encrypt(rsaPublicKey, test.ConvertToByteArray());

            Assert.IsNotEmpty(armoredBytes);
            var clearBytes = rsa.Decrypt(rsaPrivateKey, armoredBytes);

            Assert.AreEqual(test, clearBytes.ConvertToString());
        }