using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace Crypto
{
   class Program
   {
      static void Main(string[] args)
      {
         RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
         StreamReader sr = File.OpenText(@"..\..\..\..\JanesKey.xml");
         string rsaXml = sr.ReadToEnd();
         sr.Close();
         rsa.FromXmlString(rsaXml);

         string messageToJane = "Cześć Asiu, z tej strony Janek. Co u Ciebie słychać?";

         byte[] encrypted = rsa.Encrypt(
           System.Text.Encoding.GetEncoding(1250).GetBytes(messageToJane), false);

         FileStream fs = new FileStream(@"..\..\..\..\MessageToJane.dat", FileMode.Create);
         fs.Write(encrypted, 0, encrypted.Length);
         fs.Close();
      }
   }
}
