title: Decrypt a byte[] signed with a private key
body: <p>I have two XML files with private and public keys generated by the RSACryptoServiceProvider class. I have turned a random string into a byte array, and using the private key, I have encrypted it. But how do I use the public key to decrypt the byte[] again? Here's what I have so far:</p>
  
  <pre><code>    class Program
      {
          static void Main(string[] args)
          {
              RSACryptoServiceProvider encryptor = new RSACryptoServiceProvider();
              encryptor.FromXmlString(GetPrivateKey());
  
  
              string unencryptedString = "This string could only have been send by me.";
  
              byte[] unencryptedByteArray = Encoding.Unicode.GetBytes(unencryptedString);
  
              byte[] encryptedByteArray = encryptor.SignData(unencryptedByteArray, new SHA1CryptoServiceProvider());
  
              byte[] decryptedByteArray; //how do I decrypt the array again?
  
              string decryptedString = System.Text.Encoding.Unicode.GetString(decryptedByteArray);
  
              Console.WriteLine(decryptedString);
  
              Console.ReadKey();
          }
  
          private static string GetPrivateKey()
          {
              using (TextReader reader = new StreamReader(@"path to private key file generated by the ToXmlString method"))
              {
                  string privateKey = reader.ReadToEnd();
                  reader.Close();
                  return privateKey;
              }
          }
  
          private static string GetPublicKey()
          {
              using (TextReader reader = new StreamReader(@"path to public key file generated by the ToXmlString method"))
              {
                  string privateKey = reader.ReadToEnd();
                  reader.Close();
                  return privateKey;
              }
          }
      }
  </code></pre>