title: Porting code from c++ to c# - Encrypting with RSA PKCS#1 private key
body: <p>I'm trying to port this piece of code from c++ to c#:</p>
  
  <pre><code>...
  strPrivateKey = "someBase64EncodedPrivateKey";
  long sizeKey = DecodeBase64(strPrivateKey, pKey);
  const unsigned char* _pKey = pKey;
  d2i_RSAPrivateKey(&amp;pRSA, &amp;_pKey, sizeKey);
  ...
  
  RSA_private_encrypt(sizeOfMessage, pMessage, pSignature, pRSA, RSA_PKCS1_PADDING);
  
  ...
  </code></pre>
  
  <p>So far here is my code:</p>
  
  <pre><code>var strPrivateKey = "someBase64EncodedPrivateKey";
  var bytes = Convert.FromBase64String(strPrivateKey);
  
  var rsa = new RSACryptoServiceProvider();
  
  // How to set the private key to the rsa object?!
  
  byte[] someDataToEncrypt = /* Set the data to encrypt */;
  var encryptedData = rsa.Encrypt(someDataToEncrypt, false);
  </code></pre>
  
  <p>EDIT:
  I'm not ever sure if it's the class I should refer to.</p>
  
  <p>Thanks</p>