title: RSACryptoServiceProvider encrypt and decrypt using own public and private key
body: <p>I'm told that for asymmetric cryptography you encrypt plaintext with your public key and decrypt it with your private key. So i've tried the following:</p>
  
  <pre><code>    static void Main(string[] args)
      {
          RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
          string pubkey = rsa.ToXmlString(false);
          string prikey = rsa.ToXmlString(true);
  
          byte[] someThing = RSAEncrypt(Encoding.Unicode.GetBytes("Hello World"), pubkey);
          byte[] anotherThing = RSADecrypt(someThing, prikey);
  
          Console.WriteLine(Convert.ToBase64String(anotherThing));
      }
  </code></pre>
  
  <p>and the encrypt and decrypt functions</p>
  
  <pre><code>    public static byte[] RSAEncrypt(byte[] plaintext, string destKey)
      {
          byte[] encryptedData;
          RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
          rsa.FromXmlString(destKey);
          encryptedData = rsa.Encrypt(plaintext, true);
          rsa.Dispose();
          return encryptedData;
      }
  
      public static byte[] RSADecrypt(byte[] ciphertext, string srcKey)
      {
          byte[] decryptedData;
          RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
          rsa.FromXmlString(srcKey);
          decryptedData = rsa.Decrypt(ciphertext, true);
          rsa.Dispose();
          return decryptedData;
      }
  </code></pre>
  
  <p>I'm expecting the console to display <code>Hello World</code>, but it displays this <code>SABlAGwAbABvACAAVwBvAHIAbABkAA==</code>. Am i using RSACryptoServiceProvider wrongly?</p>