public RSAParameters RSAPublicParameters()
        {
            RSAPrivKeyClient rSAPrivKeyClient = new RSAPrivKeyClient();
            RSAParameters    rSAParameters    = rSAPrivKeyClient.PublicParameters;

            return(rSAParameters);
        }
        private void RSAPublic()
        {
            var bob       = new RSAPrivKeyClient();
            var pk        = bob.PublicParameters;
            var alice     = new RSAPubKeyClient(pk);
            var encrypted = alice.Encrypt(new byte[] { 0, 1, 2, 3 });
            var decrypted = bob.Decrypt(encrypted);

            Console.WriteLine(decrypted);
        }
        public string RSADecrypt(string encryptedText)
        {
            // Get the bytes of the string
            byte[]           bytesToBeDecrypted = Convert.FromBase64String(encryptedText);
            RSAPrivKeyClient rSAPrivKeyClient   = new RSAPrivKeyClient();

            byte[] bytesDecrypted = rSAPrivKeyClient.Decrypt(bytesToBeDecrypted);
            string result         = Encoding.UTF8.GetString(bytesDecrypted);

            return(result);
        }
        public string RSAEncrypt(string plainText)
        {
            // Get the bytes of the string
            byte[] bytesToBeEncrypted = Encoding.UTF8.GetBytes(plainText);

            RSAPrivKeyClient rSAPrivKeyClient = new RSAPrivKeyClient();
            var pk = rSAPrivKeyClient.PublicParameters;

            RSAPubKeyClient rSAPubKeyClient = new RSAPubKeyClient(pk);
            var             encrypted       = rSAPubKeyClient.Encrypt(bytesToBeEncrypted);

            string result = Convert.ToBase64String(encrypted);

            return(result);
        }