Laravel.io
private static string publicKey = "generate key ile ürettikten sonra buraya tamamını yapıştırın.";
private static string privateKey = "generate key ile ürettikten sonra buraya tamamını yapıştırın.";
 
public enum KeySizes
        {
            SIZE_512 = 512,
            SIZE_1024 = 1024,
            SIZE_2048 = 2048,
            SIZE_952 = 952,
            SIZE_1369 = 1369
        };

private void button1_Click(object sender, EventArgs e)
        {
            //generateKeys();

            string message = "sample string";

            byte[] encrypted = Encrypt(Encoding.UTF8.GetBytes(message));
            byte[] decrypted = Decrypt(encrypted);

            Console.WriteLine("Original\n\t " + message + "\n");
            Console.WriteLine("Encrypted\n\t" + BitConverter.ToString(encrypted).Replace("-","") + "\n");
            Console.WriteLine("Decrypted\n\t" + Encoding.UTF8.GetString(decrypted));
        }

private static void generateKeys()
        {
            using (var rsa = new RSACryptoServiceProvider((int)KeySizes.SIZE_2048))
            {
                rsa.PersistKeyInCsp = false;

                publicKey = rsa.ToXmlString(false);
                Console.WriteLine(publicKey);
                privateKey = rsa.ToXmlString(true);
                Console.WriteLine(privateKey);
            }
        }

        private static byte[] Encrypt(byte[] input)
        {
            byte[] encrypted;
            using (var rsa = new RSACryptoServiceProvider((int)KeySizes.SIZE_2048))
            {
                rsa.PersistKeyInCsp = false;
                rsa.FromXmlString(publicKey);
                encrypted = rsa.Encrypt(input, true);
            }
            return encrypted;
        }

        private static byte[] Decrypt(byte[] input)
        {
            byte[] decrypted;
            using (var rsa = new RSACryptoServiceProvider((int)KeySizes.SIZE_2048))
            {
                rsa.PersistKeyInCsp = false;
                rsa.FromXmlString(privateKey);
                decrypted = rsa.Decrypt(input, true);
            }
            return decrypted;
        }

Please note that all pasted data is publicly available.